From f122e76c03c4049d56b75795737a4f03bab30a4e Mon Sep 17 00:00:00 2001 From: KCarretto Date: Thu, 10 Aug 2023 20:25:58 -0400 Subject: [PATCH] Rename everything (#263) * session -> beacon: tavern tests pass * session -> beacon: rust & UI, all tests pass * job -> quest * Missed a few, it's good now * Removed accidentally copied port scanner --- README.md | 22 +- docs/_docs/dev-guide/eldritch.md | 12 +- docs/_docs/dev-guide/tavern.md | 41 +- docs/_docs/user-guide/imix.md | 6 +- ..._create_job.png => realm_create_quest.png} | 0 docs/pages/index.md | 10 +- docs/pages/user-guide.md | 6 +- go.sum | 2 + implants/imix/src/main.rs | 64 +- implants/lib/tavern/README.md | 2 +- implants/lib/tavern/graphql/mutations.graphql | 2 +- implants/lib/tavern/graphql/schema.graphql | 482 +-- implants/lib/tavern/src/http.rs | 8 +- implants/lib/tavern/src/lib.rs | 16 +- implants/lib/tavern/src/mutations.rs | 56 +- tavern/e2e_test.go | 88 +- tavern/ent/{session.go => beacon.go} | 184 +- .../{session/session.go => beacon/beacon.go} | 20 +- tavern/ent/beacon/where.go | 757 ++++ tavern/ent/beacon_create.go | 461 +++ tavern/ent/beacon_delete.go | 88 + tavern/ent/beacon_query.go | 768 ++++ tavern/ent/beacon_update.go | 1038 +++++ tavern/ent/client.go | 558 +-- tavern/ent/ent.go | 18 +- tavern/ent/gql_collection.go | 214 +- tavern/ent/gql_edge.go | 78 +- tavern/ent/gql_mutation_input.go | 92 +- tavern/ent/gql_node.go | 58 +- tavern/ent/gql_pagination.go | 654 +-- tavern/ent/gql_where_input.go | 1862 ++++----- tavern/ent/hook/hook.go | 36 +- tavern/ent/job_create.go | 409 -- tavern/ent/job_delete.go | 88 - tavern/ent/job_query.go | 874 ---- tavern/ent/migrate/schema.go | 130 +- tavern/ent/mutation.go | 2996 +++++++------- tavern/ent/predicate/predicate.go | 10 +- tavern/ent/privacy/privacy.go | 60 +- tavern/ent/{job.go => quest.go} | 178 +- tavern/ent/{job/job.go => quest/quest.go} | 34 +- tavern/ent/{job => quest}/where.go | 274 +- tavern/ent/quest_create.go | 409 ++ tavern/ent/quest_delete.go | 88 + tavern/ent/quest_query.go | 874 ++++ tavern/ent/{job_update.go => quest_update.go} | 540 +-- tavern/ent/runtime/runtime.go | 102 +- tavern/ent/schema/{session.go => beacon.go} | 34 +- tavern/ent/schema/{job.go => quest.go} | 24 +- tavern/ent/schema/tag.go | 2 +- tavern/ent/schema/task.go | 4 +- tavern/ent/session/where.go | 757 ---- tavern/ent/session_create.go | 461 --- tavern/ent/session_delete.go | 88 - tavern/ent/session_query.go | 768 ---- tavern/ent/session_update.go | 1038 ----- tavern/ent/tag.go | 38 +- tavern/ent/tag/tag.go | 20 +- tavern/ent/tag/where.go | 14 +- tavern/ent/tag_create.go | 28 +- tavern/ent/tag_query.go | 94 +- tavern/ent/tag_update.go | 134 +- tavern/ent/task.go | 70 +- tavern/ent/task/task.go | 40 +- tavern/ent/task/where.go | 28 +- tavern/ent/task_create.go | 56 +- tavern/ent/task_query.go | 114 +- tavern/ent/task_update.go | 156 +- tavern/ent/tx.go | 14 +- .../{session_test.go => beacon_test.go} | 136 +- tavern/graphql/generated/ent.generated.go | 3588 ++++++++--------- tavern/graphql/generated/inputs.generated.go | 10 +- .../graphql/generated/mutation.generated.go | 142 +- tavern/graphql/generated/root_.generated.go | 1048 ++--- tavern/graphql/gqlgen.yml | 6 +- tavern/graphql/models/gqlgen_models.go | 16 +- tavern/graphql/mutation.resolvers.go | 72 +- tavern/graphql/query.resolvers.go | 16 +- tavern/graphql/query_test.go | 26 +- tavern/graphql/{job_test.go => quest_test.go} | 76 +- tavern/graphql/schema.graphql | 482 +-- tavern/graphql/schema/ent.graphql | 538 +-- tavern/graphql/schema/inputs.graphql | 14 +- tavern/graphql/schema/mutation.graphql | 8 +- tavern/graphql/schema/query.graphql | 4 +- tavern/graphql/tag_test.go | 40 +- ...ExistingSession.yml => ExistingBeacon.yml} | 8 +- .../testdata/mutations/claimTasks/Filters.yml | 22 +- .../mutations/claimTasks/MultiTask.yml | 14 +- .../{NewSession.yml => NewBeacon.yml} | 4 +- .../testdata/mutations/claimTasks/OneTask.yml | 12 +- .../{createJob => createQuest}/NoFiles.yml | 24 +- .../{createJob => createQuest}/WithFiles.yml | 24 +- .../testdata/mutations/createTag/Group.yml | 8 +- ...ltipleSessions.yml => MultipleBeacons.yml} | 10 +- .../testdata/mutations/createTag/Service.yml | 8 +- .../mutations/createTome/WithFiles.yml | 2 +- .../mutations/submitTaskResult/Append.yml | 12 +- .../mutations/submitTaskResult/OneAndDone.yml | 12 +- .../AddTag.yml | 10 +- .../ChangeHostname.yml | 10 +- .../RemoveTag.yml | 12 +- .../mutations/updateTag/ChangeName.yml | 2 +- .../{sessions => beacons}/FilterByID.yml | 10 +- .../{sessions => beacons}/Singular.yml | 8 +- .../queries/{jobs => quests}/FilterByID.yml | 16 +- .../queries/{jobs => quests}/Singular.yml | 12 +- tavern/internal/www/schema.graphql | 564 +-- tavern/internal/www/src/App.tsx | 14 +- .../BeaconFilterBar.tsx} | 38 +- .../components/beacon-filter-bar/index.tsx | 1 + .../BeaconOption.tsx} | 32 +- .../step-job-status/index.tsx | 1 - .../CreateQuestDrawer.tsx} | 6 +- .../drawer-form/DrawerForm.tsx | 16 +- .../drawer-form/index.tsx | 0 .../drawer-form/validation.tsx | 8 +- .../StepCustomizeParameters.tsx | 0 .../step-icon/StepIcon.tsx | 0 .../step-icon/index.tsx | 0 .../step-quest-status/StepQuestStatus.tsx} | 6 +- .../step-quest-status/index.tsx | 1 + .../step-select-targets/StepSelectTargets.tsx | 36 +- .../tab-filter-targets/TabFilterTargets.tsx | 32 +- .../tab-filter-targets/index.tsx | 0 .../search-filter/SearchFilter.tsx | 80 +- .../search-filter/index.tsx | 0 .../TabSelectedTargets.tsx | 30 +- .../tab-selected-targets/index.tsx | 0 .../step-select-tome/StepSelectTome.tsx | 0 .../components/page-wrapper/PageWrapper.tsx | 8 +- .../components/session-filter-bar/index.tsx | 1 - .../internal/www/src/context/TagContext.tsx | 2 +- ...useSessionFilter.ts => useBeaconFilter.ts} | 60 +- tavern/internal/www/src/hooks/useJobList.ts | 8 - tavern/internal/www/src/hooks/useQuestList.ts | 8 + .../{useSubmitJob.ts => useSubmitQuest.ts} | 32 +- tavern/internal/www/src/index.tsx | 2 +- .../www/src/pages/create-job/index.tsx | 1 - .../create-job/select-sessions/index.tsx | 1 - .../select-sessions/session-view/index.tsx | 1 - .../CreateQuest.tsx} | 24 +- .../www/src/pages/create-quest/index.tsx | 1 + .../select-beacons/SelectBeacons.tsx} | 40 +- .../beacon-view/BeaconView.tsx} | 70 +- .../select-beacons/beacon-view/index.tsx | 1 + .../create-quest/select-beacons/index.tsx | 1 + .../select-tome/SelectTome.tsx | 46 +- .../select-tome/index.tsx | 0 .../validation.tsx | 16 +- .../internal/www/src/pages/job-list/index.tsx | 1 - .../JobList.tsx => quest-list/QuestList.tsx} | 18 +- .../www/src/pages/quest-list/index.tsx | 1 + tavern/internal/www/src/utils/consts.ts | 12 +- tavern/internal/www/src/utils/queries.ts | 6 +- tavern/test_data.go | 102 +- tavern/test_data_test.go | 26 +- 157 files changed, 13334 insertions(+), 13233 deletions(-) rename docs/assets/img/{realm_create_job.png => realm_create_quest.png} (100%) rename tavern/ent/{session.go => beacon.go} (54%) rename tavern/ent/{session/session.go => beacon/beacon.go} (92%) create mode 100644 tavern/ent/beacon/where.go create mode 100644 tavern/ent/beacon_create.go create mode 100644 tavern/ent/beacon_delete.go create mode 100644 tavern/ent/beacon_query.go create mode 100644 tavern/ent/beacon_update.go delete mode 100644 tavern/ent/job_create.go delete mode 100644 tavern/ent/job_delete.go delete mode 100644 tavern/ent/job_query.go rename tavern/ent/{job.go => quest.go} (56%) rename tavern/ent/{job/job.go => quest/quest.go} (87%) rename tavern/ent/{job => quest}/where.go (51%) create mode 100644 tavern/ent/quest_create.go create mode 100644 tavern/ent/quest_delete.go create mode 100644 tavern/ent/quest_query.go rename tavern/ent/{job_update.go => quest_update.go} (51%) rename tavern/ent/schema/{session.go => beacon.go} (71%) rename tavern/ent/schema/{job.go => quest.go} (69%) delete mode 100644 tavern/ent/session/where.go delete mode 100644 tavern/ent/session_create.go delete mode 100644 tavern/ent/session_delete.go delete mode 100644 tavern/ent/session_query.go delete mode 100644 tavern/ent/session_update.go rename tavern/graphql/{session_test.go => beacon_test.go} (64%) rename tavern/graphql/{job_test.go => quest_test.go} (68%) rename tavern/graphql/testdata/mutations/claimTasks/{ExistingSession.yml => ExistingBeacon.yml} (55%) rename tavern/graphql/testdata/mutations/claimTasks/{NewSession.yml => NewBeacon.yml} (72%) rename tavern/graphql/testdata/mutations/{createJob => createQuest}/NoFiles.yml (68%) rename tavern/graphql/testdata/mutations/{createJob => createQuest}/WithFiles.yml (79%) rename tavern/graphql/testdata/mutations/createTag/{MultipleSessions.yml => MultipleBeacons.yml} (81%) rename tavern/graphql/testdata/mutations/{updateSession => updateBeacon}/AddTag.yml (70%) rename tavern/graphql/testdata/mutations/{updateSession => updateBeacon}/ChangeHostname.yml (65%) rename tavern/graphql/testdata/mutations/{updateSession => updateBeacon}/RemoveTag.yml (66%) rename tavern/graphql/testdata/queries/{sessions => beacons}/FilterByID.yml (68%) rename tavern/graphql/testdata/queries/{sessions => beacons}/Singular.yml (76%) rename tavern/graphql/testdata/queries/{jobs => quests}/FilterByID.yml (58%) rename tavern/graphql/testdata/queries/{jobs => quests}/Singular.yml (69%) rename tavern/internal/www/src/components/{session-filter-bar/SessionFilterBar.tsx => beacon-filter-bar/BeaconFilterBar.tsx} (62%) create mode 100644 tavern/internal/www/src/components/beacon-filter-bar/index.tsx rename tavern/internal/www/src/components/{session-option/SessionOption.tsx => beacon-option/BeaconOption.tsx} (52%) delete mode 100644 tavern/internal/www/src/components/create-job-drawer/step-job-status/index.tsx rename tavern/internal/www/src/components/{create-job-drawer/CreateJobDrawer.tsx => create-quest-drawer/CreateQuestDrawer.tsx} (84%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/drawer-form/DrawerForm.tsx (69%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/drawer-form/index.tsx (100%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/drawer-form/validation.tsx (60%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-customize-parameters/StepCustomizeParameters.tsx (100%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-icon/StepIcon.tsx (100%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-icon/index.tsx (100%) rename tavern/internal/www/src/components/{create-job-drawer/step-job-status/StepJobStatus.tsx => create-quest-drawer/step-quest-status/StepQuestStatus.tsx} (91%) create mode 100644 tavern/internal/www/src/components/create-quest-drawer/step-quest-status/index.tsx rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-targets/StepSelectTargets.tsx (85%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-targets/tab-filter-targets/TabFilterTargets.tsx (76%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-targets/tab-filter-targets/index.tsx (100%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-targets/tab-filter-targets/search-filter/SearchFilter.tsx (64%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-targets/tab-filter-targets/search-filter/index.tsx (100%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-targets/tab-selected-targets/TabSelectedTargets.tsx (76%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-targets/tab-selected-targets/index.tsx (100%) rename tavern/internal/www/src/components/{create-job-drawer => create-quest-drawer}/step-select-tome/StepSelectTome.tsx (100%) delete mode 100644 tavern/internal/www/src/components/session-filter-bar/index.tsx rename tavern/internal/www/src/hooks/{useSessionFilter.ts => useBeaconFilter.ts} (55%) delete mode 100644 tavern/internal/www/src/hooks/useJobList.ts create mode 100644 tavern/internal/www/src/hooks/useQuestList.ts rename tavern/internal/www/src/hooks/{useSubmitJob.ts => useSubmitQuest.ts} (59%) delete mode 100644 tavern/internal/www/src/pages/create-job/index.tsx delete mode 100644 tavern/internal/www/src/pages/create-job/select-sessions/index.tsx delete mode 100644 tavern/internal/www/src/pages/create-job/select-sessions/session-view/index.tsx rename tavern/internal/www/src/pages/{create-job/CreateJob.tsx => create-quest/CreateQuest.tsx} (77%) create mode 100644 tavern/internal/www/src/pages/create-quest/index.tsx rename tavern/internal/www/src/pages/{create-job/select-sessions/SelectSessions.tsx => create-quest/select-beacons/SelectBeacons.tsx} (55%) rename tavern/internal/www/src/pages/{create-job/select-sessions/session-view/SessionView.tsx => create-quest/select-beacons/beacon-view/BeaconView.tsx} (70%) create mode 100644 tavern/internal/www/src/pages/create-quest/select-beacons/beacon-view/index.tsx create mode 100644 tavern/internal/www/src/pages/create-quest/select-beacons/index.tsx rename tavern/internal/www/src/pages/{create-job => create-quest}/select-tome/SelectTome.tsx (66%) rename tavern/internal/www/src/pages/{create-job => create-quest}/select-tome/index.tsx (100%) rename tavern/internal/www/src/pages/{create-job => create-quest}/validation.tsx (50%) delete mode 100644 tavern/internal/www/src/pages/job-list/index.tsx rename tavern/internal/www/src/pages/{job-list/JobList.tsx => quest-list/QuestList.tsx} (73%) create mode 100644 tavern/internal/www/src/pages/quest-list/index.tsx diff --git a/README.md b/README.md index a48709b4e..f873e611b 100644 --- a/README.md +++ b/README.md @@ -4,43 +4,49 @@ # Realm + ![test-status](https://github.com/kcarretto/realm/actions/workflows/tests.yml/badge.svg?branch=main) [![codecov](https://codecov.io/github/kcarretto/realm/branch/main/graph/badge.svg?token=KSRPHYDIE4)](https://app.codecov.io/github/kcarretto/realm) [![Go Report Card](https://goreportcard.com/badge/github.com/kcarretto/realm)](https://goreportcard.com/report/github.com/kcarretto/realm) [![Rust Report Card](https://rust-reportcard.xuri.me/badge/github.com/kcarretto/realm)](https://rust-reportcard.xuri.me/report/github.com/kcarretto/realm) [![Docs](https://img.shields.io/badge/read%20our-docs-informational)](https://docs.realm.pub/) +Realm is a cross platform Red Team engagement platform with a focus on automation and reliability. -Realm is a cross platform Red Team engagement platform with a focus on automation and reliability. - -![realm-logo](./docs/assets/img/realm_create_job.png) +![realm-logo](./docs/assets/img/realm_create_quest.png) ## Features + ### Agent (imix) + - Written in rust with support for MacOS, Linux, and Windows. -- Supports long running jobs by reading output from jobs in real time. +- Supports long running tasks by reading output from tasks in real time. - Interval callback times. - Simple file based configuration. - Embedded files. - Built-in interpreter. ### Server (tavern) + - Web interface. - Group actions. - graphql backend for easy API access. - OAuth login support. - Cloud native deployment with pre-made terraform for production deployments. - ### Built-in interpreter (eldritch) + - Reflective DLL Loader. - Port scanning. - Remote execution over SSH. - And much much more: https://docs.realm.pub/user-guide/eldritch ## Quickstart guide + *To deploy a production ready instance see the [tavern setup guide](https://docs.realm.pub/user-guide/tavern).* + ### Start the server + ```bash git clone https://github.com/KCarretto/realm.git cd realm @@ -49,7 +55,9 @@ go run ./tavern # If you'd like to test without deploying an agent use the test data. ENABLE_TEST_DATA=1 go run ./tavern ``` + ### Start the agent + ```bash git clone https://github.com/KCarretto/realm.git cd realm/implants/imix @@ -78,6 +86,6 @@ cargo run -- -c /tmp/imix-config.json ``` - ## Want to contribute start here -https://docs.realm.pub/dev-guide/introduction + + diff --git a/docs/_docs/dev-guide/eldritch.md b/docs/_docs/dev-guide/eldritch.md index 85464303c..81c017785 100644 --- a/docs/_docs/dev-guide/eldritch.md +++ b/docs/_docs/dev-guide/eldritch.md @@ -1,6 +1,6 @@ --- title: Eldritch -tags: +tags: - Dev Guide description: Want to implement new functionality in the agent? Start here! permalink: dev-guide/eldritch @@ -219,7 +219,7 @@ struct OsInfo { } fn handle_get_os() -> Result { - return Ok(OsInfo { + return Ok(OsInfo { arch: whoami::arch().to_string(), }); } @@ -262,12 +262,12 @@ PR #[238](https://github.com/KCarretto/realm/pull/238/files) This PR implements # Notes about asynchronous Eldritch code --- ### Async example -In order to run concurrent tasks we need to build an asynchronous function. This is useful if you're building a function that needs to do two things at once or that can benefit from running discrete jobs in parallel. +In order to run concurrent tasks we need to build an asynchronous function. This is useful if you're building a function that needs to do two things at once or that can benefit from running discrete tasks in parallel. The starlark bindings we're using to create Eldritch are not asynchronous therefore the Eldritch function itself cannot be asynchronous. To get around this we use the [`tokio::runtime::Runtime.block_on()`](https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.html#method.block_on) function in conjunction with two asynchronous helpers. -We'll create the following three functions to manage concurrent tasks: +We'll create the following three functions to manage concurrent tasks: * `pub fn function` - Eldritch function implementation which will implement the `tokio::runtime::Runtime.block_on()` function. * `async fn handle_function` - Async helper function that will start, track, and join async tasks. * `async fn run_function` - Async function runner that gets spawned by the `handle_function` function. @@ -290,7 +290,7 @@ async fn handle_function(arg1: Vec) -> Result> { all_result_futures.push(task::spawn(resulting_future)); } - // Await results of each job. + // Await results of each task. // We are not acting on scan results independently so it's okay to loop through each and only return when all have finished. for task in all_result_futures { match task.await? { @@ -323,7 +323,7 @@ pub fn function(arg1: Vec) -> Result> { ``` **Implementation tips:** -* If running a lot of concurrent tasks the system may run out of open file descriptors. Either handle this error with a wait and retry, or proactively rate limit your tasks well below the default limits. +* If running a lot of concurrent tasks the system may run out of open file descriptors. Either handle this error with a wait and retry, or proactively rate limit your tasks well below the default limits. ### Testing async code requires some additional work diff --git a/docs/_docs/dev-guide/tavern.md b/docs/_docs/dev-guide/tavern.md index d31428a8a..2733eac1b 100644 --- a/docs/_docs/dev-guide/tavern.md +++ b/docs/_docs/dev-guide/tavern.md @@ -131,10 +131,12 @@ If you'd like to explore the Graph API and try out some queries, head to the `/g ![/assets/img/tavern/graphiql.png](/assets/img/tavern/graphiql.png) #### Some sample queries to get started -**List all sessions** + +##### List all beacons + ```graphql -query get_sessions { - sessions { +query get_beacons { + beacons { id identifier name @@ -145,15 +147,17 @@ query get_sessions { } ``` -**Create a tome** +##### Create a tome + ```graphql mutation CreateTome ($input: CreateTomeInput!) { createTome(input: $input) { id name } -} +} ``` + ```json { "input": { @@ -161,19 +165,21 @@ mutation CreateTome ($input: CreateTomeInput!) { "description": "Just a sample", "eldritch": "print(input_params['print_string'])", "fileIDs": [], - "paramDefs": "{\"print_string\":\"str\"}" + "paramDefs": "[{\"name\":\"print_string\",\"label\":\"Print String\",\"type\":\"string\",\"placeholder\":\"A message to print\"}]" } } ``` -**Create a job** +##### Create a task + ```graphql -mutation createJob($input: CreateJobInput!, $sess:[ID!]!){ - createJob(input: $input, sessionIDs: $sess) { +mutation createQuest($input: CreateQuestInput!, $beaconIDs:[ID!]!){ + createQuest(input: $input, beaconIDs: $beaconIDs) { id } } ``` + ```json { "input": { @@ -184,14 +190,16 @@ mutation createJob($input: CreateJobInput!, $sess:[ID!]!){ "sess": ["8589934593"] } ``` -**Get all task and job output** + +##### Get all task and quest output + ```graphql query get_task_res { - jobs { + quests { tasks { id output - job { + quest { tome { eldritch } @@ -203,7 +211,6 @@ query get_task_res { } ``` - ### Creating a New Model 1. Initialize the schema `cd tavern && go run entgo.io/ent/cmd/ent init ` @@ -241,7 +248,7 @@ query get_task_res { |-----|-----------|--------| |state| SQL queries that define the initial db state before the query is run.| no | |requestor| Holds information about the authenticated context making the query. | no | -|requestor.session_token| Session token corresponding to the user for authentication. You may create a user with a predetermined session token using the `state` field. | no | +|requestor.beacon_token| Session token corresponding to the user for authentication. You may create a user with a predetermined session token using the `state` field. | no | |query| GraphQL query or mutation to be executed | yes | |variables| A map of variables that will be passed with your GraphQL Query to the server | no | |expected| A map that defines the expected response that the server should return | no | @@ -278,7 +285,7 @@ GraphQL mutations enable clients to _mutate_ or modify backend data. Tavern supp "hostname": "test", "hostIdentifier": "dodo", "agentIdentifier": "bleep", - "sessionIdentifier": "123" + "beaconIdentifier": "123" } }, "operationName": "ClaimTasks" @@ -289,13 +296,13 @@ In the above example, `$input` is used to pass variables from code to the GraphQ ### Claiming Tasks -The first GraphQL mutation an agent should utilize is `claimTasks`. This mutation is used to fetch new tasks from Tavern that should be executed by the agent. In order to fetch execution information, the agent should perform a graph traversal to obtain information about the associated job. For example: +The first GraphQL mutation an agent should utilize is `claimTasks`. This mutation is used to fetch new tasks from Tavern that should be executed by the agent. In order to fetch execution information, the agent should perform a graph traversal to obtain information about the associated quest. For example: ```graphql mutation ClaimTasks($input: ClaimTasksInput!) { claimTasks(input: $input) { id - job { + quest { tome { id eldritch diff --git a/docs/_docs/user-guide/imix.md b/docs/_docs/user-guide/imix.md index 74a129d7e..d70081e86 100644 --- a/docs/_docs/user-guide/imix.md +++ b/docs/_docs/user-guide/imix.md @@ -1,6 +1,6 @@ --- title: Imix -tags: +tags: - User Guide description: Imix User Guide permalink: user-guide/imix @@ -49,10 +49,10 @@ The imix config is as follows: - `priority`: The index that a domain should have. - `uri`: The full URI of the callback endpoint. -## Functionality +## Functionality Imix derives all it's functionality from the eldritch language. See the [Eldritch User Guide](/user-guide/eldritch) for more information. ## Task management Imix can execute up to 127 threads concurrently after that the main imix thread will block behind other threads. -Every callback interval imix will query each active thread for new output and rely that back to the c2. This means even long running jobs will report their status as new data comes in. +Every callback interval imix will query each active thread for new output and rely that back to the c2. This means even long running tasks will report their status as new data comes in. diff --git a/docs/assets/img/realm_create_job.png b/docs/assets/img/realm_create_quest.png similarity index 100% rename from docs/assets/img/realm_create_job.png rename to docs/assets/img/realm_create_quest.png diff --git a/docs/pages/index.md b/docs/pages/index.md index e87a79244..84eebfeca 100644 --- a/docs/pages/index.md +++ b/docs/pages/index.md @@ -7,11 +7,11 @@ permalink: / # Welcome to Realm! ## User Guide -Realm is a cross platform Red Team engagement platform with a focus on automation and reliability. +Realm is a cross platform Red Team engagement platform with a focus on automation and reliability. Want to get hands on now? Follow this guide to setup a dev instance of realm. -![realm-logo](/assets/img/realm_create_job.png) +![realm-logo](/assets/img/realm_create_quest.png)
Server (tavern)
    @@ -25,7 +25,7 @@ Want to get hands on now? Agent (imix)
    • Written in rust with support for MacOS, Linux, and Windows.
    • -
    • Supports long running jobs by reading output from jobs in real time.
    • +
    • Supports long running tasks by reading output from tasks in real time.
    • Interval callback times.
    • Simple file based configuration.
    • Embedded files.
    • @@ -50,12 +50,12 @@ Want to get hands on now?
      - {% for post in site.docs %} + {% for post in site.docs %} {% if post.url contains 'dev-guide' %} {% else %} {% continue %} - {% endif %} + {% endif %}
      {{ post.title }}

      {{ post.description }}

      diff --git a/docs/pages/user-guide.md b/docs/pages/user-guide.md index a33d1d08f..49b2b67c1 100644 --- a/docs/pages/user-guide.md +++ b/docs/pages/user-guide.md @@ -7,11 +7,11 @@ permalink: /user-guide/ # User Guide ## User Guide -Realm is a cross platform Red Team engagement platform with a focus on automation and reliability. +Realm is a cross platform Red Team engagement platform with a focus on automation and reliability. Want to get hands on now? Follow this guide to setup a dev instance of realm. -![realm-logo](/assets/img/realm_create_job.png) +![realm-logo](/assets/img/realm_create_quest.png)
      Server (tavern)
        @@ -25,7 +25,7 @@ Want to get hands on now? Agent (imix)
        • Written in rust with support for MacOS, Linux, and Windows.
        • -
        • Supports long running jobs by reading output from jobs in real time.
        • +
        • Supports long running tasks by reading output from task in real time.
        • Interval callback times.
        • Simple file based configuration.
        • Embedded files.
        • diff --git a/go.sum b/go.sum index 5295fa87f..d84f9705e 100644 --- a/go.sum +++ b/go.sum @@ -88,12 +88,14 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU= github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4= github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/implants/imix/src/main.rs b/implants/imix/src/main.rs index b302c0228..87143057f 100644 --- a/implants/imix/src/main.rs +++ b/implants/imix/src/main.rs @@ -40,16 +40,16 @@ async fn handle_exec_tome(task: Task, print_channel_sender: Sender) -> R // TODO: Download auxillary files from CDN // Read a tome script - // let task_job = match task.job { - // Some(job) => job, - // None => return Ok(("".to_string(), format!("No job associated for task ID: {}", task.id))), + // let task_quest = match task.quest { + // Some(quest) => quest, + // None => return Ok(("".to_string(), format!("No quest associated for task ID: {}", task.id))), // }; - - let task_job = task.job; - let tome_filename = task_job.tome.name; - let tome_contents = task_job.tome.eldritch; - let tome_parameters = task_job.parameters; + let task_quest = task.quest; + + let tome_filename = task_quest.tome.name; + let tome_contents = task_quest.tome.eldritch; + let tome_parameters = task_quest.parameters; let print_handler = EldritchPrintHandler{ sender: print_channel_sender }; @@ -58,7 +58,7 @@ async fn handle_exec_tome(task: Task, print_channel_sender: Sender) -> R Ok(local_thread_res) => local_thread_res, Err(_) => todo!(), }; - // let res = eldritch_run(tome_name, tome_contents, task_job.parameters, &print_handler); + // let res = eldritch_run(tome_name, tome_contents, task_quest.parameters, &print_handler); match res { Ok(tome_output) => Ok((tome_output, "".to_string())), Err(tome_error) => Ok(("".to_string(), tome_error.to_string())), @@ -84,7 +84,7 @@ async fn handle_exec_timeout_and_response(task: Task, print_channel_sender: Send // let tome_result = tokio::task::spawn(exec_future).await??; // let tome_result = tokio::spawn(exec_future).await??; - + print_channel_sender.clone().send(format!("---[RESULT]----\n{}\n---------",tome_result.0))?; print_channel_sender.clone().send(format!("---[ERROR]----\n{}\n--------",tome_result.1))?; @@ -99,9 +99,9 @@ fn get_hostname() -> Result { Ok(whoami::hostname()) } -fn get_session_id() -> Result { - let session_id = Uuid::new_v4(); - Ok(session_id.to_string()) +fn get_beacon_id() -> Result { + let beacon_id = Uuid::new_v4(); + Ok(beacon_id.to_string()) } fn get_host_id(host_id_file_path: String) -> Result { @@ -177,7 +177,7 @@ async fn main_loop(config_path: String, run_once: bool) -> Result<()> { let config_file = File::open(config_path)?; let imix_config: imix::Config = serde_json::from_reader(config_file)?; - // This hashmap tracks all jobs by their ID (key) and a tuple value: (future, channel_reciever) + // This hashmap tracks all tasks by their ID (key) and a tuple value: (future, channel_reciever) let mut all_exec_futures: HashMap = HashMap::new(); let principal = match get_principal() { @@ -200,11 +200,11 @@ async fn main_loop(config_path: String, run_once: bool) -> Result<()> { }, }; - let session_id = match get_session_id() { - Ok(tmp_session_id) => tmp_session_id, + let beacon_id = match get_beacon_id() { + Ok(tmp_beacon_id) => tmp_beacon_id, Err(error) => { if debug { - return Err(anyhow::anyhow!("Unable to get a random session id\n{}", error)); + return Err(anyhow::anyhow!("Unable to get a random beacon id\n{}", error)); } "DANGER-UNKNOWN".to_string() }, @@ -243,7 +243,7 @@ async fn main_loop(config_path: String, run_once: bool) -> Result<()> { let claim_tasks_input = ClaimTasksInput { principal: principal, hostname: hostname, - session_identifier: session_id, + beacon_identifier: beacon_id, host_identifier: host_id, agent_identifier: format!("{}-{}","imix",version_string), host_platform, @@ -274,15 +274,15 @@ async fn main_loop(config_path: String, run_once: bool) -> Result<()> { if debug { println!("[{}]: Starting {} new tasks", (Utc::now().time() - start_time).num_milliseconds(), new_tasks.len()); } // 2. Start new tasks for task in new_tasks { - if debug { println!("Launching:\n{:?}", task.clone().job.tome.eldritch); } + if debug { println!("Launching:\n{:?}", task.clone().quest.tome.eldritch); } let (sender, receiver) = channel::(); let exec_with_timeout = handle_exec_timeout_and_response(task.clone(), sender.clone()); if debug { println!("[{}]: Queueing task {}", (Utc::now().time() - start_time).num_milliseconds(), task.clone().id); } match all_exec_futures.insert(task.clone().id, ExecTask{ - future_join_handle: task::spawn(exec_with_timeout), - start_time: Utc::now(), - graphql_task: task.clone(), + future_join_handle: task::spawn(exec_with_timeout), + start_time: Utc::now(), + graphql_task: task.clone(), print_reciever: receiver, }) { Some(_old_task) => { @@ -418,7 +418,7 @@ pub fn main() -> Result<(), imix::Error> { mod tests { use httptest::{Server, Expectation, matchers::{request}, responders::status_code, all_of}; use httptest::matchers::matches; - use tavern::{Job, Tome, SubmitTaskResultResponseData, SubmitTaskResult, GraphQLResponse, ClaimTasksResponseData}; + use tavern::{Quest, Tome, SubmitTaskResultResponseData, SubmitTaskResult, GraphQLResponse, ClaimTasksResponseData}; use tempfile::NamedTempFile; use super::*; @@ -433,9 +433,9 @@ mod tests { }; assert!((primary_ip_address != "DANGER-UNKNOWN".to_string())) } - + #[test] - fn imix_test_get_os_pretty_name() { + fn imix_test_get_os_pretty_name() { let res = get_os_pretty_name().unwrap(); assert!(!res.contains("UNKNOWN")); } @@ -444,7 +444,7 @@ mod tests { fn imix_handle_exec_tome() { let test_tome_input = Task{ id: "17179869185".to_string(), - job: Job { + quest: Quest { id: "4294967297".to_string(), name: "Test Exec".to_string(), parameters: Some(r#"{"cmd":"whoami"}"#.to_string()), @@ -474,7 +474,7 @@ sys.shell(input_params["cmd"])["stdout"] // Define a future for our execution task let exec_future = handle_exec_tome(test_tome_input, sender.clone()); let result = runtime.block_on(exec_future).unwrap(); - + let stdout = receiver.recv_timeout(Duration::from_millis(500)).unwrap(); assert_eq!(stdout, "custom_print_handler_test".to_string()); @@ -519,9 +519,9 @@ sys.shell(input_params["cmd"])["stdout"] .body(serde_json::to_string(&post_result_response)?)) ); - let test_task = Task { + let test_task = Task { id: test_task_id, - job: Job { + quest: Quest { id:"4294967297".to_string(), name: "Exec stuff".to_string(), parameters: None, @@ -603,7 +603,7 @@ print("main_loop_test_success")"#.to_string(), #[test] fn imix_test_main_loop_run_once() -> Result<()> { let test_task_id = "17179869185".to_string(); - + // Response expectations are poped in reverse order. let server = Server::run(); @@ -627,9 +627,9 @@ print("main_loop_test_success")"#.to_string(), let claim_task_response = GraphQLResponse { data: Some(ClaimTasksResponseData { claim_tasks: vec![ - Task { + Task { id: test_task_id.clone(), - job: Job { + quest: Quest { id:"4294967297".to_string(), name: "Exec stuff".to_string(), parameters: Some(r#"{"cmd":"echo main_loop_test_success"}"#.to_string()), diff --git a/implants/lib/tavern/README.md b/implants/lib/tavern/README.md index 053e8d05b..4794461a5 100644 --- a/implants/lib/tavern/README.md +++ b/implants/lib/tavern/README.md @@ -25,7 +25,7 @@ async fn main() { // Fetch new tasks let tasks: Vec = client.claim_tasks(ClaimTasksInput{ agent_identifier: String::from("example"), - session_identifier: String::from("123456"), + beacon_identifier: String::from("123456"), host_identifier: String::from("ABCDEFG"), principal: String::from("root"), hostname: String::from("web"), diff --git a/implants/lib/tavern/graphql/mutations.graphql b/implants/lib/tavern/graphql/mutations.graphql index 79fa1034a..caf1a3b70 100644 --- a/implants/lib/tavern/graphql/mutations.graphql +++ b/implants/lib/tavern/graphql/mutations.graphql @@ -1,7 +1,7 @@ mutation ClaimTasks($input: ClaimTasksInput!) { claimTasks(input: $input) { id, - job { + quest { id, name, parameters, diff --git a/implants/lib/tavern/graphql/schema.graphql b/implants/lib/tavern/graphql/schema.graphql index 44acd4cd8..aed90d9d6 100644 --- a/implants/lib/tavern/graphql/schema.graphql +++ b/implants/lib/tavern/graphql/schema.graphql @@ -5,14 +5,204 @@ enum Role { USER }directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +type Beacon implements Node { + id: ID! + """A human readable identifier for the beacon.""" + name: String! + """The identity the beacon is authenticated as (e.g. 'root')""" + principal: String + """The hostname of the system the beacon is running on.""" + hostname: String + """Unique identifier for the beacon. Unique to each instance of the beacon.""" + identifier: String! + """Identifies the agent that the beacon is running as (e.g. 'imix').""" + agentIdentifier: String + """Unique identifier for the host the beacon is running on.""" + hostIdentifier: String + """Primary interface IP address reported by the agent.""" + hostPrimaryIP: String + """Platform the agent is operating on.""" + hostPlatform: BeaconHostPlatform! + """Timestamp of when a task was last claimed or updated for the beacon.""" + lastSeenAt: Time + tags: [Tag!] + tasks: [Task!] +} +"""BeaconHostPlatform is enum for the field host_platform""" +enum BeaconHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/beacon.HostPlatform") { + Windows + Linux + MacOS + BSD + Unknown +} +"""Ordering options for Beacon connections""" +input BeaconOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Beacons.""" + field: BeaconOrderField! +} +"""Properties by which Beacon connections can be ordered.""" +enum BeaconOrderField { + LAST_SEEN_AT +} +""" +BeaconWhereInput is used for filtering Beacon objects. +Input was generated by ent. +""" +input BeaconWhereInput { + not: BeaconWhereInput + and: [BeaconWhereInput!] + or: [BeaconWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """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 + principalIsNil: Boolean + principalNotNil: Boolean + principalEqualFold: String + principalContainsFold: String + """hostname field predicates""" + hostname: String + hostnameNEQ: String + hostnameIn: [String!] + hostnameNotIn: [String!] + hostnameGT: String + hostnameGTE: String + hostnameLT: String + hostnameLTE: String + hostnameContains: String + hostnameHasPrefix: String + hostnameHasSuffix: String + hostnameIsNil: Boolean + hostnameNotNil: Boolean + hostnameEqualFold: String + hostnameContainsFold: String + """identifier field predicates""" + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """agent_identifier field predicates""" + agentIdentifier: String + agentIdentifierNEQ: String + agentIdentifierIn: [String!] + agentIdentifierNotIn: [String!] + agentIdentifierGT: String + agentIdentifierGTE: String + agentIdentifierLT: String + agentIdentifierLTE: String + agentIdentifierContains: String + agentIdentifierHasPrefix: String + agentIdentifierHasSuffix: String + agentIdentifierIsNil: Boolean + agentIdentifierNotNil: Boolean + agentIdentifierEqualFold: String + agentIdentifierContainsFold: String + """host_identifier field predicates""" + hostIdentifier: String + hostIdentifierNEQ: String + hostIdentifierIn: [String!] + hostIdentifierNotIn: [String!] + hostIdentifierGT: String + hostIdentifierGTE: String + hostIdentifierLT: String + hostIdentifierLTE: String + hostIdentifierContains: String + hostIdentifierHasPrefix: String + hostIdentifierHasSuffix: String + hostIdentifierIsNil: Boolean + hostIdentifierNotNil: Boolean + hostIdentifierEqualFold: String + hostIdentifierContainsFold: String + """host_primary_ip field predicates""" + hostPrimaryIP: String + hostPrimaryIPNEQ: String + hostPrimaryIPIn: [String!] + hostPrimaryIPNotIn: [String!] + hostPrimaryIPGT: String + hostPrimaryIPGTE: String + hostPrimaryIPLT: String + hostPrimaryIPLTE: String + hostPrimaryIPContains: String + hostPrimaryIPHasPrefix: String + hostPrimaryIPHasSuffix: String + hostPrimaryIPIsNil: Boolean + hostPrimaryIPNotNil: Boolean + hostPrimaryIPEqualFold: String + hostPrimaryIPContainsFold: String + """host_platform field predicates""" + hostPlatform: BeaconHostPlatform + hostPlatformNEQ: BeaconHostPlatform + hostPlatformIn: [BeaconHostPlatform!] + hostPlatformNotIn: [BeaconHostPlatform!] + """last_seen_at field predicates""" + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """tags edge predicates""" + hasTags: Boolean + hasTagsWith: [TagWhereInput!] + """tasks edge predicates""" + hasTasks: Boolean + hasTasksWith: [TaskWhereInput!] +} """ -CreateJobInput is used for create Job object. +CreateQuestInput is used for create Quest object. Input was generated by ent. """ -input CreateJobInput { - """Name of the job""" +input CreateQuestInput { + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tomeID: ID! } @@ -25,7 +215,7 @@ input CreateTagInput { name: String! """Describes the type of tag this is""" kind: TagKind! - sessionIDs: [ID!] + beaconIDs: [ID!] } """ CreateTomeInput is used for create Tome object. @@ -147,42 +337,42 @@ input FileWhereInput { hashEqualFold: String hashContainsFold: String } -type Job implements Node { +type Quest implements Node { id: ID! """Timestamp of when this ent was created""" createdAt: Time! """Timestamp of when this ent was last updated""" lastModifiedAt: Time! - """Name of the job""" + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tome: Tome! bundle: File tasks: [Task!] creator: User } -"""Ordering options for Job connections""" -input JobOrder { +"""Ordering options for Quest connections""" +input QuestOrder { """The ordering direction.""" direction: OrderDirection! = ASC - """The field by which to order Jobs.""" - field: JobOrderField! + """The field by which to order Quests.""" + field: QuestOrderField! } -"""Properties by which Job connections can be ordered.""" -enum JobOrderField { +"""Properties by which Quest connections can be ordered.""" +enum QuestOrderField { CREATED_AT LAST_MODIFIED_AT NAME } """ -JobWhereInput is used for filtering Job objects. +QuestWhereInput is used for filtering Quest objects. Input was generated by ent. """ -input JobWhereInput { - not: JobWhereInput - and: [JobWhereInput!] - or: [JobWhereInput!] +input QuestWhereInput { + not: QuestWhereInput + and: [QuestWhereInput!] + or: [QuestWhereInput!] """id field predicates""" id: ID idNEQ: ID @@ -294,203 +484,13 @@ type Query { ids: [ID!]! ): [Node]! } -type Session implements Node { - id: ID! - """A human readable identifier for the session.""" - name: String! - """The identity the session is authenticated as (e.g. 'root')""" - principal: String - """The hostname of the system the session is running on.""" - hostname: String - """Unique identifier for the session. Unique to each instance of the session.""" - identifier: String! - """Identifies the agent that the session is running as (e.g. 'imix').""" - agentIdentifier: String - """Unique identifier for the host the session is running on.""" - hostIdentifier: String - """Primary interface IP address reported by the agent.""" - hostPrimaryIP: String - """Platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! - """Timestamp of when a task was last claimed or updated for a target""" - lastSeenAt: Time - tags: [Tag!] - tasks: [Task!] -} -"""SessionHostPlatform is enum for the field host_platform""" -enum SessionHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/session.HostPlatform") { - Windows - Linux - MacOS - BSD - Unknown -} -"""Ordering options for Session connections""" -input SessionOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Sessions.""" - field: SessionOrderField! -} -"""Properties by which Session connections can be ordered.""" -enum SessionOrderField { - LAST_SEEN_AT -} -""" -SessionWhereInput is used for filtering Session objects. -Input was generated by ent. -""" -input SessionWhereInput { - not: SessionWhereInput - and: [SessionWhereInput!] - or: [SessionWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """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 - principalIsNil: Boolean - principalNotNil: Boolean - principalEqualFold: String - principalContainsFold: String - """hostname field predicates""" - hostname: String - hostnameNEQ: String - hostnameIn: [String!] - hostnameNotIn: [String!] - hostnameGT: String - hostnameGTE: String - hostnameLT: String - hostnameLTE: String - hostnameContains: String - hostnameHasPrefix: String - hostnameHasSuffix: String - hostnameIsNil: Boolean - hostnameNotNil: Boolean - hostnameEqualFold: String - hostnameContainsFold: String - """identifier field predicates""" - identifier: String - identifierNEQ: String - identifierIn: [String!] - identifierNotIn: [String!] - identifierGT: String - identifierGTE: String - identifierLT: String - identifierLTE: String - identifierContains: String - identifierHasPrefix: String - identifierHasSuffix: String - identifierEqualFold: String - identifierContainsFold: String - """agent_identifier field predicates""" - agentIdentifier: String - agentIdentifierNEQ: String - agentIdentifierIn: [String!] - agentIdentifierNotIn: [String!] - agentIdentifierGT: String - agentIdentifierGTE: String - agentIdentifierLT: String - agentIdentifierLTE: String - agentIdentifierContains: String - agentIdentifierHasPrefix: String - agentIdentifierHasSuffix: String - agentIdentifierIsNil: Boolean - agentIdentifierNotNil: Boolean - agentIdentifierEqualFold: String - agentIdentifierContainsFold: String - """host_identifier field predicates""" - hostIdentifier: String - hostIdentifierNEQ: String - hostIdentifierIn: [String!] - hostIdentifierNotIn: [String!] - hostIdentifierGT: String - hostIdentifierGTE: String - hostIdentifierLT: String - hostIdentifierLTE: String - hostIdentifierContains: String - hostIdentifierHasPrefix: String - hostIdentifierHasSuffix: String - hostIdentifierIsNil: Boolean - hostIdentifierNotNil: Boolean - hostIdentifierEqualFold: String - hostIdentifierContainsFold: String - """host_primary_ip field predicates""" - hostPrimaryIP: String - hostPrimaryIPNEQ: String - hostPrimaryIPIn: [String!] - hostPrimaryIPNotIn: [String!] - hostPrimaryIPGT: String - hostPrimaryIPGTE: String - hostPrimaryIPLT: String - hostPrimaryIPLTE: String - hostPrimaryIPContains: String - hostPrimaryIPHasPrefix: String - hostPrimaryIPHasSuffix: String - hostPrimaryIPIsNil: Boolean - hostPrimaryIPNotNil: Boolean - hostPrimaryIPEqualFold: String - hostPrimaryIPContainsFold: String - """host_platform field predicates""" - hostPlatform: SessionHostPlatform - hostPlatformNEQ: SessionHostPlatform - hostPlatformIn: [SessionHostPlatform!] - hostPlatformNotIn: [SessionHostPlatform!] - """last_seen_at field predicates""" - lastSeenAt: Time - lastSeenAtNEQ: Time - lastSeenAtIn: [Time!] - lastSeenAtNotIn: [Time!] - lastSeenAtGT: Time - lastSeenAtGTE: Time - lastSeenAtLT: Time - lastSeenAtLTE: Time - lastSeenAtIsNil: Boolean - lastSeenAtNotNil: Boolean - """tags edge predicates""" - hasTags: Boolean - hasTagsWith: [TagWhereInput!] - """tasks edge predicates""" - hasTasks: Boolean - hasTasksWith: [TaskWhereInput!] -} type Tag implements Node { id: ID! """Name of the tag""" name: String! """Describes the type of tag this is""" kind: TagKind! - sessions: [Session!] + beacons: [Beacon!] } """TagKind is enum for the field kind""" enum TagKind @goModel(model: "github.com/kcarretto/realm/tavern/ent/tag.Kind") { @@ -544,9 +544,9 @@ input TagWhereInput { kindNEQ: TagKind kindIn: [TagKind!] kindNotIn: [TagKind!] - """sessions edge predicates""" - hasSessions: Boolean - hasSessionsWith: [SessionWhereInput!] + """beacons edge predicates""" + hasBeacons: Boolean + hasBeaconsWith: [BeaconWhereInput!] } type Task implements Node { id: ID! @@ -564,8 +564,8 @@ type Task implements Node { output: String """Error, if any, produced while executing the Task""" error: String - job: Job! - session: Session! + quest: Quest! + beacon: Beacon! } """Ordering options for Task connections""" input TaskOrder { @@ -682,12 +682,12 @@ input TaskWhereInput { errorNotNil: Boolean errorEqualFold: String errorContainsFold: String - """job edge predicates""" - hasJob: Boolean - hasJobWith: [JobWhereInput!] - """session edge predicates""" - hasSession: Boolean - hasSessionWith: [SessionWhereInput!] + """quest edge predicates""" + hasQuest: Boolean + hasQuestWith: [QuestWhereInput!] + """beacon edge predicates""" + hasBeacon: Boolean + hasBeaconWith: [BeaconWhereInput!] } type Tome implements Node { id: ID! @@ -816,13 +816,13 @@ input TomeWhereInput { hasFilesWith: [FileWhereInput!] } """ -UpdateSessionInput is used for update Session object. +UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ -input UpdateSessionInput { - """A human readable identifier for the session.""" +input UpdateBeaconInput { + """A human readable identifier for the beacon.""" name: String - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String clearHostname: Boolean addTagIDs: [ID!] @@ -838,9 +838,9 @@ input UpdateTagInput { name: String """Describes the type of tag this is""" kind: TagKind - addSessionIDs: [ID!] - removeSessionIDs: [ID!] - clearSessions: Boolean + addBeaconIDs: [ID!] + removeBeaconIDs: [ID!] + clearBeacons: Boolean } """ UpdateUserInput is used for update User object. @@ -920,25 +920,25 @@ input UserWhereInput { isAdminNEQ: Boolean } input ClaimTasksInput { - """The identity the session is authenticated as (e.g. 'root')""" + """The identity the beacon is authenticated as (e.g. 'root')""" principal: String! - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String! """The platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! + hostPlatform: BeaconHostPlatform! """The IP address of the hosts primary interface (if available).""" hostPrimaryIP: String - """Unique identifier of the session, each running instance will be different.""" - sessionIdentifier: String! + """Unique identifier of the beacon, each running instance will be different.""" + beaconIdentifier: String! - """Unique identifier of the underlying host system the session is running on.""" + """Unique identifier of the underlying host system the beacon is running on.""" hostIdentifier: String! - """Name of the agent program the session is running as (e.g. 'imix')""" + """Name of the agent program the beacon is running as (e.g. 'imix')""" agentIdentifier: String! } @@ -962,14 +962,14 @@ input SubmitTaskResultInput { error: String }type Mutation { ### - # Job + # Quest ### - createJob(sessionIDs: [ID!]!, input: CreateJobInput!): Job @requireRole(role: USER) + createQuest(beaconIDs: [ID!]!, input: CreateQuestInput!): Quest @requireRole(role: USER) ### - # Session + # Beacon ### - updateSession(sessionID: ID!, input: UpdateSessionInput!): Session! @requireRole(role: USER) + updateBeacon(beaconID: ID!, input: UpdateBeaconInput!): Beacon! @requireRole(role: USER) ### # Tag @@ -994,8 +994,8 @@ input SubmitTaskResultInput { updateUser(userID: ID!, input: UpdateUserInput!): User @requireRole(role: ADMIN) }extend type Query { files(where: FileWhereInput): [File!]! - jobs(where: JobWhereInput): [Job!]! - sessions(where: SessionWhereInput): [Session!]! + quests(where: QuestWhereInput): [Quest!]! + beacons(where: BeaconWhereInput): [Beacon!]! tags(where: TagWhereInput): [Tag!]! tomes(where: TomeWhereInput): [Tome!]! users(where: UserWhereInput): [User!]! diff --git a/implants/lib/tavern/src/http.rs b/implants/lib/tavern/src/http.rs index 5594f0fea..8935ef42f 100644 --- a/implants/lib/tavern/src/http.rs +++ b/implants/lib/tavern/src/http.rs @@ -94,7 +94,7 @@ mod tests { #[tokio::test] async fn test_claim_tasks() { let input = ClaimTasksInput { - session_identifier: "bdf0b788-b32b-4faf-8719-93cd3955b043".to_string(), + beacon_identifier: "bdf0b788-b32b-4faf-8719-93cd3955b043".to_string(), host_identifier: "bdf0b788-b32b-4faf-8719-93cd3955b043".to_string(), agent_identifier: "imix".to_string(), principal: "root".to_string(), @@ -112,7 +112,7 @@ mod tests { "claimTasks": [ { "id":"17179869185", - "job": { + "quest": { "id":"4294967297", "name":"test_exe3", "tome": { @@ -127,7 +127,7 @@ mod tests { }, { "id":"17179869186", - "job": { + "quest": { "id":"4294967298", "name":"test_exe2", "tome": { @@ -152,7 +152,7 @@ mod tests { await. expect("failed to send graphql request"); for task in response { - assert!(task.job.name.contains("test_exe")) + assert!(task.quest.name.contains("test_exe")) } } diff --git a/implants/lib/tavern/src/lib.rs b/implants/lib/tavern/src/lib.rs index ab5fecd56..3cedb99dd 100644 --- a/implants/lib/tavern/src/lib.rs +++ b/implants/lib/tavern/src/lib.rs @@ -9,11 +9,11 @@ pub mod http; pub use mutations::claim_tasks::{ ClaimTasksInput, ClaimTasksClaimTasks as Task, - ClaimTasksClaimTasksJob as Job, - ClaimTasksClaimTasksJobTome as Tome, - ClaimTasksClaimTasksJobTomeFiles as File, - ClaimTasksClaimTasksJobBundle as Bundle, - SessionHostPlatform as HostPlatform, + ClaimTasksClaimTasksQuest as Quest, + ClaimTasksClaimTasksQuestTome as Tome, + ClaimTasksClaimTasksQuestTomeFiles as File, + ClaimTasksClaimTasksQuestBundle as Bundle, + BeaconHostPlatform as HostPlatform, ResponseData as ClaimTasksResponseData, }; pub use mutations::submit_task_result::{ @@ -132,9 +132,9 @@ mod tests { claim_tasks: vec![ Task{ id: String::from("5"), - job: Job{ + quest: Quest{ id: String::from("10"), - name: String::from("test_job"), + name: String::from("test_quest"), parameters: None, tome: Tome{ id: String::from("15"), @@ -158,7 +158,7 @@ mod tests { hostname: String::from("test"), host_platform: HostPlatform::Windows, host_primary_ip: Some(String::from("test")), - session_identifier: String::from("test"), + beacon_identifier: String::from("test"), host_identifier: String::from("test"), agent_identifier: String::from("test"), }; diff --git a/implants/lib/tavern/src/mutations.rs b/implants/lib/tavern/src/mutations.rs index d34646250..efa22d266 100644 --- a/implants/lib/tavern/src/mutations.rs +++ b/implants/lib/tavern/src/mutations.rs @@ -4,7 +4,7 @@ pub mod claim_tasks { #![allow(dead_code)] use std::result::Result; pub const OPERATION_NAME: &str = "ClaimTasks"; - pub const QUERY : & str = "mutation ClaimTasks($input: ClaimTasksInput!) {\n claimTasks(input: $input) {\n id,\n job {\n id,\n name,\n parameters,\n tome {\n id,\n name,\n description,\n paramDefs,\n eldritch,\n files {\n id,\n name,\n size,\n hash,\n }\n },\n bundle {\n id,\n name,\n size,\n hash,\n }\n }\n }\n}\n\nmutation SubmitTaskResult($input: SubmitTaskResultInput!) {\n submitTaskResult(input: $input) {\n id\n }\n}" ; + pub const QUERY : & str = "mutation ClaimTasks($input: ClaimTasksInput!) {\n claimTasks(input: $input) {\n id,\n quest {\n id,\n name,\n parameters,\n tome {\n id,\n name,\n description,\n paramDefs,\n eldritch,\n files {\n id,\n name,\n size,\n hash,\n }\n },\n bundle {\n id,\n name,\n size,\n hash,\n }\n }\n }\n}\n\nmutation SubmitTaskResult($input: SubmitTaskResultInput!) {\n submitTaskResult(input: $input) {\n id\n }\n}" ; use super::*; use serde::{Deserialize, Serialize}; #[allow(dead_code)] @@ -16,7 +16,7 @@ pub mod claim_tasks { #[allow(dead_code)] type ID = String; #[derive(Clone)] - pub enum SessionHostPlatform { + pub enum BeaconHostPlatform { Windows, Linux, MacOS, @@ -24,28 +24,28 @@ pub mod claim_tasks { Unknown, Other(String), } - impl ::serde::Serialize for SessionHostPlatform { + impl ::serde::Serialize for BeaconHostPlatform { fn serialize(&self, ser: S) -> Result { ser.serialize_str(match *self { - SessionHostPlatform::Windows => "Windows", - SessionHostPlatform::Linux => "Linux", - SessionHostPlatform::MacOS => "MacOS", - SessionHostPlatform::BSD => "BSD", - SessionHostPlatform::Unknown => "Unknown", - SessionHostPlatform::Other(ref s) => &s, + BeaconHostPlatform::Windows => "Windows", + BeaconHostPlatform::Linux => "Linux", + BeaconHostPlatform::MacOS => "MacOS", + BeaconHostPlatform::BSD => "BSD", + BeaconHostPlatform::Unknown => "Unknown", + BeaconHostPlatform::Other(ref s) => &s, }) } } - impl<'de> ::serde::Deserialize<'de> for SessionHostPlatform { + impl<'de> ::serde::Deserialize<'de> for BeaconHostPlatform { fn deserialize>(deserializer: D) -> Result { let s: String = ::serde::Deserialize::deserialize(deserializer)?; match s.as_str() { - "Windows" => Ok(SessionHostPlatform::Windows), - "Linux" => Ok(SessionHostPlatform::Linux), - "MacOS" => Ok(SessionHostPlatform::MacOS), - "BSD" => Ok(SessionHostPlatform::BSD), - "Unknown" => Ok(SessionHostPlatform::Unknown), - _ => Ok(SessionHostPlatform::Other(s)), + "Windows" => Ok(BeaconHostPlatform::Windows), + "Linux" => Ok(BeaconHostPlatform::Linux), + "MacOS" => Ok(BeaconHostPlatform::MacOS), + "BSD" => Ok(BeaconHostPlatform::BSD), + "Unknown" => Ok(BeaconHostPlatform::Unknown), + _ => Ok(BeaconHostPlatform::Other(s)), } } } @@ -54,11 +54,11 @@ pub mod claim_tasks { pub principal: String, pub hostname: String, #[serde(rename = "hostPlatform")] - pub host_platform: SessionHostPlatform, + pub host_platform: BeaconHostPlatform, #[serde(rename = "hostPrimaryIP")] pub host_primary_ip: Option, - #[serde(rename = "sessionIdentifier")] - pub session_identifier: String, + #[serde(rename = "beaconIdentifier")] + pub beacon_identifier: String, #[serde(rename = "hostIdentifier")] pub host_identifier: String, #[serde(rename = "agentIdentifier")] @@ -77,35 +77,35 @@ pub mod claim_tasks { #[derive(Deserialize, Serialize, Clone)] pub struct ClaimTasksClaimTasks { pub id: ID, - pub job: ClaimTasksClaimTasksJob, + pub quest: ClaimTasksClaimTasksQuest, } #[derive(Deserialize, Serialize, Clone)] - pub struct ClaimTasksClaimTasksJob { + pub struct ClaimTasksClaimTasksQuest { pub id: ID, pub name: String, pub parameters: Option, - pub tome: ClaimTasksClaimTasksJobTome, - pub bundle: Option, + pub tome: ClaimTasksClaimTasksQuestTome, + pub bundle: Option, } #[derive(Deserialize, Serialize, Clone)] - pub struct ClaimTasksClaimTasksJobTome { + pub struct ClaimTasksClaimTasksQuestTome { pub id: ID, pub name: String, pub description: String, #[serde(rename = "paramDefs")] pub param_defs: Option, pub eldritch: String, - pub files: Option>, + pub files: Option>, } #[derive(Deserialize, Serialize, Clone)] - pub struct ClaimTasksClaimTasksJobTomeFiles { + pub struct ClaimTasksClaimTasksQuestTomeFiles { pub id: ID, pub name: String, pub size: Int, pub hash: String, } #[derive(Deserialize, Serialize, Clone)] - pub struct ClaimTasksClaimTasksJobBundle { + pub struct ClaimTasksClaimTasksQuestBundle { pub id: ID, pub name: String, pub size: Int, @@ -128,7 +128,7 @@ pub mod submit_task_result { #![allow(dead_code)] use std::result::Result; pub const OPERATION_NAME: &str = "SubmitTaskResult"; - pub const QUERY : & str = "mutation ClaimTasks($input: ClaimTasksInput!) {\n claimTasks(input: $input) {\n id,\n job {\n id,\n name,\n parameters,\n tome {\n id,\n name,\n description,\n paramDefs,\n eldritch,\n files {\n id,\n name,\n size,\n hash,\n }\n },\n bundle {\n id,\n name,\n size,\n hash,\n }\n }\n }\n}\n\nmutation SubmitTaskResult($input: SubmitTaskResultInput!) {\n submitTaskResult(input: $input) {\n id\n }\n}" ; + pub const QUERY : & str = "mutation ClaimTasks($input: ClaimTasksInput!) {\n claimTasks(input: $input) {\n id,\n quest {\n id,\n name,\n parameters,\n tome {\n id,\n name,\n description,\n paramDefs,\n eldritch,\n files {\n id,\n name,\n size,\n hash,\n }\n },\n bundle {\n id,\n name,\n size,\n hash,\n }\n }\n }\n}\n\nmutation SubmitTaskResult($input: SubmitTaskResultInput!) {\n submitTaskResult(input: $input) {\n id\n }\n}" ; use super::*; use serde::{Deserialize, Serialize}; #[allow(dead_code)] diff --git a/tavern/e2e_test.go b/tavern/e2e_test.go index c25871a2b..7ad8dd6ac 100644 --- a/tavern/e2e_test.go +++ b/tavern/e2e_test.go @@ -12,9 +12,9 @@ import ( tavern "github.com/kcarretto/realm/tavern" "github.com/kcarretto/realm/tavern/ent" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/enttest" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -41,14 +41,14 @@ func TestEndToEnd(t *testing.T) { assert.Equal(t, tavern.OKStatusText, string(body)) }) - // Helper for performing session callbacks - sessionCallback := func(t *testing.T, identifier string) (*ent.Session, claimTasksResponse) { + // Helper for performing beacon callbacks + beaconCallback := func(t *testing.T, identifier string) (*ent.Beacon, claimTasksResponse) { req := graphQLQuery{ OperationName: "ClaimTasks", Query: `mutation ClaimTasks($input: ClaimTasksInput!) { claimTasks(input: $input) { id - job { + quest { id tome { id @@ -61,12 +61,12 @@ func TestEndToEnd(t *testing.T) { }`, Variables: map[string]any{ "input": map[string]any{ - "principal": "root", - "hostname": "some_hostname", - "hostPlatform": session.HostPlatformUnknown, - "sessionIdentifier": identifier, - "hostIdentifier": "uniquely_identifies_host.For_example_a_serial_number", - "agentIdentifier": "uniquely_identifies_this_agent", + "principal": "root", + "hostname": "some_hostname", + "hostPlatform": beacon.HostPlatformUnknown, + "beaconIdentifier": identifier, + "hostIdentifier": "uniquely_identifies_host.For_example_a_serial_number", + "agentIdentifier": "uniquely_identifies_this_agent", }, }, } @@ -81,32 +81,32 @@ func TestEndToEnd(t *testing.T) { err = json.Unmarshal(body, &graphQLResp) require.NoError(t, err) - testSession, err := graph.Session.Query(). - Where(session.Identifier(identifier)). + testBeacon, err := graph.Beacon.Query(). + Where(beacon.Identifier(identifier)). Only(ctx) require.NoError(t, err) - assert.NotZero(t, testSession.LastSeenAt) - return testSession, graphQLResp + assert.NotZero(t, testBeacon.LastSeenAt) + return testBeacon, graphQLResp } var ( - createdJobID int + createdQuestID int createdTaskID int defaultTomeID int createdBundleID int ) - // Session First Callback - firstSessionIdentifier := "first_session" - t.Run("SessionFirstCallback", func(t *testing.T) { - _, resp := sessionCallback(t, firstSessionIdentifier) + // Beacon First Callback + firstBeaconIdentifier := "first_beacon" + t.Run("BeaconFirstCallback", func(t *testing.T) { + _, resp := beaconCallback(t, firstBeaconIdentifier) assert.Len(t, resp.Data.ClaimTasks, 0) }) - // Create a Job (assumes a default tome has been properly configured) - t.Run("CreateJob", func(t *testing.T) { - testSession, err := graph.Session.Query(). - Where(session.Identifier(firstSessionIdentifier)). + // Create a Quest (assumes a default tome has been properly configured) + t.Run("CreateQuest", func(t *testing.T) { + testBeacon, err := graph.Beacon.Query(). + Where(beacon.Identifier(firstBeaconIdentifier)). Only(ctx) require.NoError(t, err) @@ -116,10 +116,10 @@ func TestEndToEnd(t *testing.T) { defaultTomeID = testTome.ID req := graphQLQuery{ - OperationName: "CreateJob", - Query: "mutation CreateJob($sessionIDs: [ID!]!, $input: CreateJobInput!) { createJob(sessionIDs: $sessionIDs, input: $input) { id } }", + OperationName: "CreateQuest", + Query: "mutation CreateQuest($beaconIDs: [ID!]!, $input: CreateQuestInput!) { createQuest(beaconIDs: $beaconIDs, input: $input) { id } }", Variables: map[string]any{ - "sessionIDs": []int{testSession.ID}, + "beaconIDs": []int{testBeacon.ID}, "input": map[string]any{ "name": "unit test", "tomeID": testTome.ID, @@ -131,44 +131,44 @@ func TestEndToEnd(t *testing.T) { _, err = ts.Client().Post(testURL(ts, "graphql"), "application/json", bytes.NewBuffer(data)) require.NoError(t, err) - testJob, err := graph.Job.Query(). - Where(job.Name("unit test")). + testQuest, err := graph.Quest.Query(). + Where(quest.Name("unit test")). Only(ctx) require.NoError(t, err) - createdJobID = testJob.ID + createdQuestID = testQuest.ID - testBundle, err := testJob.Bundle(ctx) + testBundle, err := testQuest.Bundle(ctx) require.NoError(t, err) require.NotNil(t, testBundle) createdBundleID = testBundle.ID - testTasks, err := testJob.Tasks(ctx) + testTasks, err := testQuest.Tasks(ctx) require.NoError(t, err) require.NotEmpty(t, testTasks) assert.Len(t, testTasks, 1) createdTaskID = testTasks[0].ID - testTaskSession, err := testTasks[0].Session(ctx) + testTaskBeacon, err := testTasks[0].Beacon(ctx) require.NoError(t, err) - assert.Equal(t, testSession.ID, testTaskSession.ID) + assert.Equal(t, testBeacon.ID, testTaskBeacon.ID) }) - // Session Second Callback - t.Run("SessionSecondCallback", func(t *testing.T) { - _, resp := sessionCallback(t, firstSessionIdentifier) + // Beacon Second Callback + t.Run("BeaconSecondCallback", func(t *testing.T) { + _, resp := beaconCallback(t, firstBeaconIdentifier) require.NotEmpty(t, resp.Data.ClaimTasks) assert.Len(t, resp.Data.ClaimTasks, 1) - jobID := convertID(resp.Data.ClaimTasks[0].Job.ID) - assert.Equal(t, createdJobID, jobID) + questID := convertID(resp.Data.ClaimTasks[0].Quest.ID) + assert.Equal(t, createdQuestID, questID) taskID := convertID(resp.Data.ClaimTasks[0].ID) assert.Equal(t, createdTaskID, taskID) - tomeID := convertID(resp.Data.ClaimTasks[0].Job.Tome.ID) + tomeID := convertID(resp.Data.ClaimTasks[0].Quest.Tome.ID) assert.Equal(t, defaultTomeID, tomeID) - bundleID := convertID(resp.Data.ClaimTasks[0].Job.Bundle.ID) + bundleID := convertID(resp.Data.ClaimTasks[0].Quest.Bundle.ID) assert.Equal(t, createdBundleID, bundleID) }) @@ -183,8 +183,8 @@ type graphQLQuery struct { type claimTasksResponse struct { Data struct { ClaimTasks []struct { - ID string `json:"id"` - Job struct { + ID string `json:"id"` + Quest struct { ID string `json:"id"` Tome struct { ID string `json:"id"` @@ -192,7 +192,7 @@ type claimTasksResponse struct { Bundle struct { ID string `json:"id"` } `json:"bundle"` - } `json:"job"` + } `json:"quest"` } `json:"claimTasks"` } `json:"data"` } diff --git a/tavern/ent/session.go b/tavern/ent/beacon.go similarity index 54% rename from tavern/ent/session.go rename to tavern/ent/beacon.go index 0139a4d5f..9eb9bd63b 100644 --- a/tavern/ent/session.go +++ b/tavern/ent/beacon.go @@ -8,42 +8,42 @@ import ( "time" "entgo.io/ent/dialect/sql" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/beacon" ) -// Session is the model entity for the Session schema. -type Session struct { +// Beacon is the model entity for the Beacon schema. +type Beacon struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` - // A human readable identifier for the session. + // A human readable identifier for the beacon. Name string `json:"name,omitempty"` - // The identity the session is authenticated as (e.g. 'root') + // The identity the beacon is authenticated as (e.g. 'root') Principal string `json:"principal,omitempty"` - // The hostname of the system the session is running on. + // The hostname of the system the beacon is running on. Hostname string `json:"hostname,omitempty"` - // Unique identifier for the session. Unique to each instance of the session. + // Unique identifier for the beacon. Unique to each instance of the beacon. Identifier string `json:"identifier,omitempty"` - // Identifies the agent that the session is running as (e.g. 'imix'). + // Identifies the agent that the beacon is running as (e.g. 'imix'). AgentIdentifier string `json:"agent_identifier,omitempty"` - // Unique identifier for the host the session is running on. + // Unique identifier for the host the beacon is running on. HostIdentifier string `json:"host_identifier,omitempty"` // Primary interface IP address reported by the agent. HostPrimaryIP string `json:"host_primary_ip,omitempty"` // Platform the agent is operating on. - HostPlatform session.HostPlatform `json:"host_platform,omitempty"` - // Timestamp of when a task was last claimed or updated for a target + HostPlatform beacon.HostPlatform `json:"host_platform,omitempty"` + // Timestamp of when a task was last claimed or updated for the beacon. LastSeenAt time.Time `json:"last_seen_at,omitempty"` // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the SessionQuery when eager-loading is set. - Edges SessionEdges `json:"edges"` + // The values are being populated by the BeaconQuery when eager-loading is set. + Edges BeaconEdges `json:"edges"` } -// SessionEdges holds the relations/edges for other nodes in the graph. -type SessionEdges struct { - // Tags used to group the session with other sessions +// BeaconEdges holds the relations/edges for other nodes in the graph. +type BeaconEdges struct { + // Tags used to group this beacon with other beacons. Tags []*Tag `json:"tags,omitempty"` - // Tasks that have been assigned to the session + // Tasks that have been assigned to the beacon. Tasks []*Task `json:"tasks,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. @@ -57,7 +57,7 @@ type SessionEdges struct { // TagsOrErr returns the Tags value or an error if the edge // was not loaded in eager-loading. -func (e SessionEdges) TagsOrErr() ([]*Tag, error) { +func (e BeaconEdges) TagsOrErr() ([]*Tag, error) { if e.loadedTypes[0] { return e.Tags, nil } @@ -66,7 +66,7 @@ func (e SessionEdges) TagsOrErr() ([]*Tag, error) { // TasksOrErr returns the Tasks value or an error if the edge // was not loaded in eager-loading. -func (e SessionEdges) TasksOrErr() ([]*Task, error) { +func (e BeaconEdges) TasksOrErr() ([]*Task, error) { if e.loadedTypes[1] { return e.Tasks, nil } @@ -74,206 +74,206 @@ func (e SessionEdges) TasksOrErr() ([]*Task, error) { } // scanValues returns the types for scanning values from sql.Rows. -func (*Session) scanValues(columns []string) ([]any, error) { +func (*Beacon) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case session.FieldID: + case beacon.FieldID: values[i] = new(sql.NullInt64) - case session.FieldName, session.FieldPrincipal, session.FieldHostname, session.FieldIdentifier, session.FieldAgentIdentifier, session.FieldHostIdentifier, session.FieldHostPrimaryIP, session.FieldHostPlatform: + case beacon.FieldName, beacon.FieldPrincipal, beacon.FieldHostname, beacon.FieldIdentifier, beacon.FieldAgentIdentifier, beacon.FieldHostIdentifier, beacon.FieldHostPrimaryIP, beacon.FieldHostPlatform: values[i] = new(sql.NullString) - case session.FieldLastSeenAt: + case beacon.FieldLastSeenAt: values[i] = new(sql.NullTime) default: - return nil, fmt.Errorf("unexpected column %q for type Session", columns[i]) + return nil, fmt.Errorf("unexpected column %q for type Beacon", columns[i]) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Session fields. -func (s *Session) assignValues(columns []string, values []any) error { +// to the Beacon fields. +func (b *Beacon) 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 session.FieldID: + case beacon.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - s.ID = int(value.Int64) - case session.FieldName: + b.ID = int(value.Int64) + case beacon.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - s.Name = value.String + b.Name = value.String } - case session.FieldPrincipal: + case beacon.FieldPrincipal: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field principal", values[i]) } else if value.Valid { - s.Principal = value.String + b.Principal = value.String } - case session.FieldHostname: + case beacon.FieldHostname: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field hostname", values[i]) } else if value.Valid { - s.Hostname = value.String + b.Hostname = value.String } - case session.FieldIdentifier: + case beacon.FieldIdentifier: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field identifier", values[i]) } else if value.Valid { - s.Identifier = value.String + b.Identifier = value.String } - case session.FieldAgentIdentifier: + case beacon.FieldAgentIdentifier: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field agent_identifier", values[i]) } else if value.Valid { - s.AgentIdentifier = value.String + b.AgentIdentifier = value.String } - case session.FieldHostIdentifier: + case beacon.FieldHostIdentifier: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field host_identifier", values[i]) } else if value.Valid { - s.HostIdentifier = value.String + b.HostIdentifier = value.String } - case session.FieldHostPrimaryIP: + case beacon.FieldHostPrimaryIP: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field host_primary_ip", values[i]) } else if value.Valid { - s.HostPrimaryIP = value.String + b.HostPrimaryIP = value.String } - case session.FieldHostPlatform: + case beacon.FieldHostPlatform: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field host_platform", values[i]) } else if value.Valid { - s.HostPlatform = session.HostPlatform(value.String) + b.HostPlatform = beacon.HostPlatform(value.String) } - case session.FieldLastSeenAt: + case beacon.FieldLastSeenAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field last_seen_at", values[i]) } else if value.Valid { - s.LastSeenAt = value.Time + b.LastSeenAt = value.Time } } } return nil } -// QueryTags queries the "tags" edge of the Session entity. -func (s *Session) QueryTags() *TagQuery { - return NewSessionClient(s.config).QueryTags(s) +// QueryTags queries the "tags" edge of the Beacon entity. +func (b *Beacon) QueryTags() *TagQuery { + return NewBeaconClient(b.config).QueryTags(b) } -// QueryTasks queries the "tasks" edge of the Session entity. -func (s *Session) QueryTasks() *TaskQuery { - return NewSessionClient(s.config).QueryTasks(s) +// QueryTasks queries the "tasks" edge of the Beacon entity. +func (b *Beacon) QueryTasks() *TaskQuery { + return NewBeaconClient(b.config).QueryTasks(b) } -// Update returns a builder for updating this Session. -// Note that you need to call Session.Unwrap() before calling this method if this Session +// Update returns a builder for updating this Beacon. +// Note that you need to call Beacon.Unwrap() before calling this method if this Beacon // was returned from a transaction, and the transaction was committed or rolled back. -func (s *Session) Update() *SessionUpdateOne { - return NewSessionClient(s.config).UpdateOne(s) +func (b *Beacon) Update() *BeaconUpdateOne { + return NewBeaconClient(b.config).UpdateOne(b) } -// Unwrap unwraps the Session entity that was returned from a transaction after it was closed, +// Unwrap unwraps the Beacon 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 (s *Session) Unwrap() *Session { - _tx, ok := s.config.driver.(*txDriver) +func (b *Beacon) Unwrap() *Beacon { + _tx, ok := b.config.driver.(*txDriver) if !ok { - panic("ent: Session is not a transactional entity") + panic("ent: Beacon is not a transactional entity") } - s.config.driver = _tx.drv - return s + b.config.driver = _tx.drv + return b } // String implements the fmt.Stringer. -func (s *Session) String() string { +func (b *Beacon) String() string { var builder strings.Builder - builder.WriteString("Session(") - builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) + builder.WriteString("Beacon(") + builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) builder.WriteString("name=") - builder.WriteString(s.Name) + builder.WriteString(b.Name) builder.WriteString(", ") builder.WriteString("principal=") - builder.WriteString(s.Principal) + builder.WriteString(b.Principal) builder.WriteString(", ") builder.WriteString("hostname=") - builder.WriteString(s.Hostname) + builder.WriteString(b.Hostname) builder.WriteString(", ") builder.WriteString("identifier=") - builder.WriteString(s.Identifier) + builder.WriteString(b.Identifier) builder.WriteString(", ") builder.WriteString("agent_identifier=") - builder.WriteString(s.AgentIdentifier) + builder.WriteString(b.AgentIdentifier) builder.WriteString(", ") builder.WriteString("host_identifier=") - builder.WriteString(s.HostIdentifier) + builder.WriteString(b.HostIdentifier) builder.WriteString(", ") builder.WriteString("host_primary_ip=") - builder.WriteString(s.HostPrimaryIP) + builder.WriteString(b.HostPrimaryIP) builder.WriteString(", ") builder.WriteString("host_platform=") - builder.WriteString(fmt.Sprintf("%v", s.HostPlatform)) + builder.WriteString(fmt.Sprintf("%v", b.HostPlatform)) builder.WriteString(", ") builder.WriteString("last_seen_at=") - builder.WriteString(s.LastSeenAt.Format(time.ANSIC)) + builder.WriteString(b.LastSeenAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // NamedTags returns the Tags named value or an error if the edge was not // loaded in eager-loading with this name. -func (s *Session) NamedTags(name string) ([]*Tag, error) { - if s.Edges.namedTags == nil { +func (b *Beacon) NamedTags(name string) ([]*Tag, error) { + if b.Edges.namedTags == nil { return nil, &NotLoadedError{edge: name} } - nodes, ok := s.Edges.namedTags[name] + nodes, ok := b.Edges.namedTags[name] if !ok { return nil, &NotLoadedError{edge: name} } return nodes, nil } -func (s *Session) appendNamedTags(name string, edges ...*Tag) { - if s.Edges.namedTags == nil { - s.Edges.namedTags = make(map[string][]*Tag) +func (b *Beacon) appendNamedTags(name string, edges ...*Tag) { + if b.Edges.namedTags == nil { + b.Edges.namedTags = make(map[string][]*Tag) } if len(edges) == 0 { - s.Edges.namedTags[name] = []*Tag{} + b.Edges.namedTags[name] = []*Tag{} } else { - s.Edges.namedTags[name] = append(s.Edges.namedTags[name], edges...) + b.Edges.namedTags[name] = append(b.Edges.namedTags[name], edges...) } } // NamedTasks returns the Tasks named value or an error if the edge was not // loaded in eager-loading with this name. -func (s *Session) NamedTasks(name string) ([]*Task, error) { - if s.Edges.namedTasks == nil { +func (b *Beacon) NamedTasks(name string) ([]*Task, error) { + if b.Edges.namedTasks == nil { return nil, &NotLoadedError{edge: name} } - nodes, ok := s.Edges.namedTasks[name] + nodes, ok := b.Edges.namedTasks[name] if !ok { return nil, &NotLoadedError{edge: name} } return nodes, nil } -func (s *Session) appendNamedTasks(name string, edges ...*Task) { - if s.Edges.namedTasks == nil { - s.Edges.namedTasks = make(map[string][]*Task) +func (b *Beacon) appendNamedTasks(name string, edges ...*Task) { + if b.Edges.namedTasks == nil { + b.Edges.namedTasks = make(map[string][]*Task) } if len(edges) == 0 { - s.Edges.namedTasks[name] = []*Task{} + b.Edges.namedTasks[name] = []*Task{} } else { - s.Edges.namedTasks[name] = append(s.Edges.namedTasks[name], edges...) + b.Edges.namedTasks[name] = append(b.Edges.namedTasks[name], edges...) } } -// Sessions is a parsable slice of Session. -type Sessions []*Session +// Beacons is a parsable slice of Beacon. +type Beacons []*Beacon diff --git a/tavern/ent/session/session.go b/tavern/ent/beacon/beacon.go similarity index 92% rename from tavern/ent/session/session.go rename to tavern/ent/beacon/beacon.go index c34acf5b0..7bd5b08aa 100644 --- a/tavern/ent/session/session.go +++ b/tavern/ent/beacon/beacon.go @@ -1,6 +1,6 @@ // Code generated by ent, DO NOT EDIT. -package session +package beacon import ( "fmt" @@ -9,8 +9,8 @@ import ( ) const ( - // Label holds the string label denoting the session type in the database. - Label = "session" + // Label holds the string label denoting the beacon type in the database. + Label = "beacon" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldName holds the string denoting the name field in the database. @@ -35,10 +35,10 @@ const ( EdgeTags = "tags" // EdgeTasks holds the string denoting the tasks edge name in mutations. EdgeTasks = "tasks" - // Table holds the table name of the session in the database. - Table = "sessions" + // Table holds the table name of the beacon in the database. + Table = "beacons" // TagsTable is the table that holds the tags relation/edge. The primary key declared below. - TagsTable = "session_tags" + TagsTable = "beacon_tags" // TagsInverseTable is the table name for the Tag entity. // It exists in this package in order to avoid circular dependency with the "tag" package. TagsInverseTable = "tags" @@ -48,10 +48,10 @@ const ( // It exists in this package in order to avoid circular dependency with the "task" package. TasksInverseTable = "tasks" // TasksColumn is the table column denoting the tasks relation/edge. - TasksColumn = "task_session" + TasksColumn = "task_beacon" ) -// Columns holds all SQL columns for session fields. +// Columns holds all SQL columns for beacon fields. var Columns = []string{ FieldID, FieldName, @@ -68,7 +68,7 @@ var Columns = []string{ var ( // TagsPrimaryKey and TagsColumn2 are the table columns denoting the // primary key for the tags relation (M2M). - TagsPrimaryKey = []string{"session_id", "tag_id"} + TagsPrimaryKey = []string{"beacon_id", "tag_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -125,7 +125,7 @@ func HostPlatformValidator(hp HostPlatform) error { case HostPlatformWindows, HostPlatformLinux, HostPlatformMacOS, HostPlatformBSD, HostPlatformUnknown: return nil default: - return fmt.Errorf("session: invalid enum value for host_platform field: %q", hp) + return fmt.Errorf("beacon: invalid enum value for host_platform field: %q", hp) } } diff --git a/tavern/ent/beacon/where.go b/tavern/ent/beacon/where.go new file mode 100644 index 000000000..1982f776a --- /dev/null +++ b/tavern/ent/beacon/where.go @@ -0,0 +1,757 @@ +// Code generated by ent, DO NOT EDIT. + +package beacon + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/kcarretto/realm/tavern/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldID, id)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldName, v)) +} + +// Principal applies equality check predicate on the "principal" field. It's identical to PrincipalEQ. +func Principal(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldPrincipal, v)) +} + +// Hostname applies equality check predicate on the "hostname" field. It's identical to HostnameEQ. +func Hostname(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldHostname, v)) +} + +// Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. +func Identifier(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldIdentifier, v)) +} + +// AgentIdentifier applies equality check predicate on the "agent_identifier" field. It's identical to AgentIdentifierEQ. +func AgentIdentifier(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldAgentIdentifier, v)) +} + +// HostIdentifier applies equality check predicate on the "host_identifier" field. It's identical to HostIdentifierEQ. +func HostIdentifier(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldHostIdentifier, v)) +} + +// HostPrimaryIP applies equality check predicate on the "host_primary_ip" field. It's identical to HostPrimaryIPEQ. +func HostPrimaryIP(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldHostPrimaryIP, v)) +} + +// LastSeenAt applies equality check predicate on the "last_seen_at" field. It's identical to LastSeenAtEQ. +func LastSeenAt(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldLastSeenAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContainsFold(FieldName, v)) +} + +// PrincipalEQ applies the EQ predicate on the "principal" field. +func PrincipalEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldPrincipal, v)) +} + +// PrincipalNEQ applies the NEQ predicate on the "principal" field. +func PrincipalNEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldPrincipal, v)) +} + +// PrincipalIn applies the In predicate on the "principal" field. +func PrincipalIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldPrincipal, vs...)) +} + +// PrincipalNotIn applies the NotIn predicate on the "principal" field. +func PrincipalNotIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldPrincipal, vs...)) +} + +// PrincipalGT applies the GT predicate on the "principal" field. +func PrincipalGT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldPrincipal, v)) +} + +// PrincipalGTE applies the GTE predicate on the "principal" field. +func PrincipalGTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldPrincipal, v)) +} + +// PrincipalLT applies the LT predicate on the "principal" field. +func PrincipalLT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldPrincipal, v)) +} + +// PrincipalLTE applies the LTE predicate on the "principal" field. +func PrincipalLTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldPrincipal, v)) +} + +// PrincipalContains applies the Contains predicate on the "principal" field. +func PrincipalContains(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContains(FieldPrincipal, v)) +} + +// PrincipalHasPrefix applies the HasPrefix predicate on the "principal" field. +func PrincipalHasPrefix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasPrefix(FieldPrincipal, v)) +} + +// PrincipalHasSuffix applies the HasSuffix predicate on the "principal" field. +func PrincipalHasSuffix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasSuffix(FieldPrincipal, v)) +} + +// PrincipalIsNil applies the IsNil predicate on the "principal" field. +func PrincipalIsNil() predicate.Beacon { + return predicate.Beacon(sql.FieldIsNull(FieldPrincipal)) +} + +// PrincipalNotNil applies the NotNil predicate on the "principal" field. +func PrincipalNotNil() predicate.Beacon { + return predicate.Beacon(sql.FieldNotNull(FieldPrincipal)) +} + +// PrincipalEqualFold applies the EqualFold predicate on the "principal" field. +func PrincipalEqualFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEqualFold(FieldPrincipal, v)) +} + +// PrincipalContainsFold applies the ContainsFold predicate on the "principal" field. +func PrincipalContainsFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContainsFold(FieldPrincipal, v)) +} + +// HostnameEQ applies the EQ predicate on the "hostname" field. +func HostnameEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldHostname, v)) +} + +// HostnameNEQ applies the NEQ predicate on the "hostname" field. +func HostnameNEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldHostname, v)) +} + +// HostnameIn applies the In predicate on the "hostname" field. +func HostnameIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldHostname, vs...)) +} + +// HostnameNotIn applies the NotIn predicate on the "hostname" field. +func HostnameNotIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldHostname, vs...)) +} + +// HostnameGT applies the GT predicate on the "hostname" field. +func HostnameGT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldHostname, v)) +} + +// HostnameGTE applies the GTE predicate on the "hostname" field. +func HostnameGTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldHostname, v)) +} + +// HostnameLT applies the LT predicate on the "hostname" field. +func HostnameLT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldHostname, v)) +} + +// HostnameLTE applies the LTE predicate on the "hostname" field. +func HostnameLTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldHostname, v)) +} + +// HostnameContains applies the Contains predicate on the "hostname" field. +func HostnameContains(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContains(FieldHostname, v)) +} + +// HostnameHasPrefix applies the HasPrefix predicate on the "hostname" field. +func HostnameHasPrefix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasPrefix(FieldHostname, v)) +} + +// HostnameHasSuffix applies the HasSuffix predicate on the "hostname" field. +func HostnameHasSuffix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasSuffix(FieldHostname, v)) +} + +// HostnameIsNil applies the IsNil predicate on the "hostname" field. +func HostnameIsNil() predicate.Beacon { + return predicate.Beacon(sql.FieldIsNull(FieldHostname)) +} + +// HostnameNotNil applies the NotNil predicate on the "hostname" field. +func HostnameNotNil() predicate.Beacon { + return predicate.Beacon(sql.FieldNotNull(FieldHostname)) +} + +// HostnameEqualFold applies the EqualFold predicate on the "hostname" field. +func HostnameEqualFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEqualFold(FieldHostname, v)) +} + +// HostnameContainsFold applies the ContainsFold predicate on the "hostname" field. +func HostnameContainsFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContainsFold(FieldHostname, v)) +} + +// IdentifierEQ applies the EQ predicate on the "identifier" field. +func IdentifierEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldIdentifier, v)) +} + +// IdentifierNEQ applies the NEQ predicate on the "identifier" field. +func IdentifierNEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldIdentifier, v)) +} + +// IdentifierIn applies the In predicate on the "identifier" field. +func IdentifierIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldIdentifier, vs...)) +} + +// IdentifierNotIn applies the NotIn predicate on the "identifier" field. +func IdentifierNotIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldIdentifier, vs...)) +} + +// IdentifierGT applies the GT predicate on the "identifier" field. +func IdentifierGT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldIdentifier, v)) +} + +// IdentifierGTE applies the GTE predicate on the "identifier" field. +func IdentifierGTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldIdentifier, v)) +} + +// IdentifierLT applies the LT predicate on the "identifier" field. +func IdentifierLT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldIdentifier, v)) +} + +// IdentifierLTE applies the LTE predicate on the "identifier" field. +func IdentifierLTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldIdentifier, v)) +} + +// IdentifierContains applies the Contains predicate on the "identifier" field. +func IdentifierContains(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContains(FieldIdentifier, v)) +} + +// IdentifierHasPrefix applies the HasPrefix predicate on the "identifier" field. +func IdentifierHasPrefix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasPrefix(FieldIdentifier, v)) +} + +// IdentifierHasSuffix applies the HasSuffix predicate on the "identifier" field. +func IdentifierHasSuffix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasSuffix(FieldIdentifier, v)) +} + +// IdentifierEqualFold applies the EqualFold predicate on the "identifier" field. +func IdentifierEqualFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEqualFold(FieldIdentifier, v)) +} + +// IdentifierContainsFold applies the ContainsFold predicate on the "identifier" field. +func IdentifierContainsFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContainsFold(FieldIdentifier, v)) +} + +// AgentIdentifierEQ applies the EQ predicate on the "agent_identifier" field. +func AgentIdentifierEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldAgentIdentifier, v)) +} + +// AgentIdentifierNEQ applies the NEQ predicate on the "agent_identifier" field. +func AgentIdentifierNEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldAgentIdentifier, v)) +} + +// AgentIdentifierIn applies the In predicate on the "agent_identifier" field. +func AgentIdentifierIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldAgentIdentifier, vs...)) +} + +// AgentIdentifierNotIn applies the NotIn predicate on the "agent_identifier" field. +func AgentIdentifierNotIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldAgentIdentifier, vs...)) +} + +// AgentIdentifierGT applies the GT predicate on the "agent_identifier" field. +func AgentIdentifierGT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldAgentIdentifier, v)) +} + +// AgentIdentifierGTE applies the GTE predicate on the "agent_identifier" field. +func AgentIdentifierGTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldAgentIdentifier, v)) +} + +// AgentIdentifierLT applies the LT predicate on the "agent_identifier" field. +func AgentIdentifierLT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldAgentIdentifier, v)) +} + +// AgentIdentifierLTE applies the LTE predicate on the "agent_identifier" field. +func AgentIdentifierLTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldAgentIdentifier, v)) +} + +// AgentIdentifierContains applies the Contains predicate on the "agent_identifier" field. +func AgentIdentifierContains(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContains(FieldAgentIdentifier, v)) +} + +// AgentIdentifierHasPrefix applies the HasPrefix predicate on the "agent_identifier" field. +func AgentIdentifierHasPrefix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasPrefix(FieldAgentIdentifier, v)) +} + +// AgentIdentifierHasSuffix applies the HasSuffix predicate on the "agent_identifier" field. +func AgentIdentifierHasSuffix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasSuffix(FieldAgentIdentifier, v)) +} + +// AgentIdentifierIsNil applies the IsNil predicate on the "agent_identifier" field. +func AgentIdentifierIsNil() predicate.Beacon { + return predicate.Beacon(sql.FieldIsNull(FieldAgentIdentifier)) +} + +// AgentIdentifierNotNil applies the NotNil predicate on the "agent_identifier" field. +func AgentIdentifierNotNil() predicate.Beacon { + return predicate.Beacon(sql.FieldNotNull(FieldAgentIdentifier)) +} + +// AgentIdentifierEqualFold applies the EqualFold predicate on the "agent_identifier" field. +func AgentIdentifierEqualFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEqualFold(FieldAgentIdentifier, v)) +} + +// AgentIdentifierContainsFold applies the ContainsFold predicate on the "agent_identifier" field. +func AgentIdentifierContainsFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContainsFold(FieldAgentIdentifier, v)) +} + +// HostIdentifierEQ applies the EQ predicate on the "host_identifier" field. +func HostIdentifierEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldHostIdentifier, v)) +} + +// HostIdentifierNEQ applies the NEQ predicate on the "host_identifier" field. +func HostIdentifierNEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldHostIdentifier, v)) +} + +// HostIdentifierIn applies the In predicate on the "host_identifier" field. +func HostIdentifierIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldHostIdentifier, vs...)) +} + +// HostIdentifierNotIn applies the NotIn predicate on the "host_identifier" field. +func HostIdentifierNotIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldHostIdentifier, vs...)) +} + +// HostIdentifierGT applies the GT predicate on the "host_identifier" field. +func HostIdentifierGT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldHostIdentifier, v)) +} + +// HostIdentifierGTE applies the GTE predicate on the "host_identifier" field. +func HostIdentifierGTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldHostIdentifier, v)) +} + +// HostIdentifierLT applies the LT predicate on the "host_identifier" field. +func HostIdentifierLT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldHostIdentifier, v)) +} + +// HostIdentifierLTE applies the LTE predicate on the "host_identifier" field. +func HostIdentifierLTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldHostIdentifier, v)) +} + +// HostIdentifierContains applies the Contains predicate on the "host_identifier" field. +func HostIdentifierContains(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContains(FieldHostIdentifier, v)) +} + +// HostIdentifierHasPrefix applies the HasPrefix predicate on the "host_identifier" field. +func HostIdentifierHasPrefix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasPrefix(FieldHostIdentifier, v)) +} + +// HostIdentifierHasSuffix applies the HasSuffix predicate on the "host_identifier" field. +func HostIdentifierHasSuffix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasSuffix(FieldHostIdentifier, v)) +} + +// HostIdentifierIsNil applies the IsNil predicate on the "host_identifier" field. +func HostIdentifierIsNil() predicate.Beacon { + return predicate.Beacon(sql.FieldIsNull(FieldHostIdentifier)) +} + +// HostIdentifierNotNil applies the NotNil predicate on the "host_identifier" field. +func HostIdentifierNotNil() predicate.Beacon { + return predicate.Beacon(sql.FieldNotNull(FieldHostIdentifier)) +} + +// HostIdentifierEqualFold applies the EqualFold predicate on the "host_identifier" field. +func HostIdentifierEqualFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEqualFold(FieldHostIdentifier, v)) +} + +// HostIdentifierContainsFold applies the ContainsFold predicate on the "host_identifier" field. +func HostIdentifierContainsFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContainsFold(FieldHostIdentifier, v)) +} + +// HostPrimaryIPEQ applies the EQ predicate on the "host_primary_ip" field. +func HostPrimaryIPEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPNEQ applies the NEQ predicate on the "host_primary_ip" field. +func HostPrimaryIPNEQ(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPIn applies the In predicate on the "host_primary_ip" field. +func HostPrimaryIPIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldHostPrimaryIP, vs...)) +} + +// HostPrimaryIPNotIn applies the NotIn predicate on the "host_primary_ip" field. +func HostPrimaryIPNotIn(vs ...string) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldHostPrimaryIP, vs...)) +} + +// HostPrimaryIPGT applies the GT predicate on the "host_primary_ip" field. +func HostPrimaryIPGT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPGTE applies the GTE predicate on the "host_primary_ip" field. +func HostPrimaryIPGTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPLT applies the LT predicate on the "host_primary_ip" field. +func HostPrimaryIPLT(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPLTE applies the LTE predicate on the "host_primary_ip" field. +func HostPrimaryIPLTE(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPContains applies the Contains predicate on the "host_primary_ip" field. +func HostPrimaryIPContains(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContains(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPHasPrefix applies the HasPrefix predicate on the "host_primary_ip" field. +func HostPrimaryIPHasPrefix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasPrefix(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPHasSuffix applies the HasSuffix predicate on the "host_primary_ip" field. +func HostPrimaryIPHasSuffix(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldHasSuffix(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPIsNil applies the IsNil predicate on the "host_primary_ip" field. +func HostPrimaryIPIsNil() predicate.Beacon { + return predicate.Beacon(sql.FieldIsNull(FieldHostPrimaryIP)) +} + +// HostPrimaryIPNotNil applies the NotNil predicate on the "host_primary_ip" field. +func HostPrimaryIPNotNil() predicate.Beacon { + return predicate.Beacon(sql.FieldNotNull(FieldHostPrimaryIP)) +} + +// HostPrimaryIPEqualFold applies the EqualFold predicate on the "host_primary_ip" field. +func HostPrimaryIPEqualFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldEqualFold(FieldHostPrimaryIP, v)) +} + +// HostPrimaryIPContainsFold applies the ContainsFold predicate on the "host_primary_ip" field. +func HostPrimaryIPContainsFold(v string) predicate.Beacon { + return predicate.Beacon(sql.FieldContainsFold(FieldHostPrimaryIP, v)) +} + +// HostPlatformEQ applies the EQ predicate on the "host_platform" field. +func HostPlatformEQ(v HostPlatform) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldHostPlatform, v)) +} + +// HostPlatformNEQ applies the NEQ predicate on the "host_platform" field. +func HostPlatformNEQ(v HostPlatform) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldHostPlatform, v)) +} + +// HostPlatformIn applies the In predicate on the "host_platform" field. +func HostPlatformIn(vs ...HostPlatform) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldHostPlatform, vs...)) +} + +// HostPlatformNotIn applies the NotIn predicate on the "host_platform" field. +func HostPlatformNotIn(vs ...HostPlatform) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldHostPlatform, vs...)) +} + +// LastSeenAtEQ applies the EQ predicate on the "last_seen_at" field. +func LastSeenAtEQ(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldLastSeenAt, v)) +} + +// LastSeenAtNEQ applies the NEQ predicate on the "last_seen_at" field. +func LastSeenAtNEQ(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldLastSeenAt, v)) +} + +// LastSeenAtIn applies the In predicate on the "last_seen_at" field. +func LastSeenAtIn(vs ...time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldLastSeenAt, vs...)) +} + +// LastSeenAtNotIn applies the NotIn predicate on the "last_seen_at" field. +func LastSeenAtNotIn(vs ...time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldLastSeenAt, vs...)) +} + +// LastSeenAtGT applies the GT predicate on the "last_seen_at" field. +func LastSeenAtGT(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldLastSeenAt, v)) +} + +// LastSeenAtGTE applies the GTE predicate on the "last_seen_at" field. +func LastSeenAtGTE(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldLastSeenAt, v)) +} + +// LastSeenAtLT applies the LT predicate on the "last_seen_at" field. +func LastSeenAtLT(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldLastSeenAt, v)) +} + +// LastSeenAtLTE applies the LTE predicate on the "last_seen_at" field. +func LastSeenAtLTE(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldLastSeenAt, v)) +} + +// LastSeenAtIsNil applies the IsNil predicate on the "last_seen_at" field. +func LastSeenAtIsNil() predicate.Beacon { + return predicate.Beacon(sql.FieldIsNull(FieldLastSeenAt)) +} + +// LastSeenAtNotNil applies the NotNil predicate on the "last_seen_at" field. +func LastSeenAtNotNil() predicate.Beacon { + return predicate.Beacon(sql.FieldNotNull(FieldLastSeenAt)) +} + +// HasTags applies the HasEdge predicate on the "tags" edge. +func HasTags() predicate.Beacon { + return predicate.Beacon(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTagsWith applies the HasEdge predicate on the "tags" edge with a given conditions (other predicates). +func HasTagsWith(preds ...predicate.Tag) predicate.Beacon { + return predicate.Beacon(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TagsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), + ) + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTasks applies the HasEdge predicate on the "tasks" edge. +func HasTasks() predicate.Beacon { + return predicate.Beacon(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, TasksTable, TasksColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTasksWith applies the HasEdge predicate on the "tasks" edge with a given conditions (other predicates). +func HasTasksWith(preds ...predicate.Task) predicate.Beacon { + return predicate.Beacon(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TasksInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, TasksTable, TasksColumn), + ) + 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.Beacon) predicate.Beacon { + return predicate.Beacon(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for _, p := range predicates { + p(s1) + } + s.Where(s1.P()) + }) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Beacon) predicate.Beacon { + return predicate.Beacon(func(s *sql.Selector) { + s1 := s.Clone().SetP(nil) + for i, p := range predicates { + if i > 0 { + s1.Or() + } + p(s1) + } + s.Where(s1.P()) + }) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Beacon) predicate.Beacon { + return predicate.Beacon(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/tavern/ent/beacon_create.go b/tavern/ent/beacon_create.go new file mode 100644 index 000000000..a15c6b53c --- /dev/null +++ b/tavern/ent/beacon_create.go @@ -0,0 +1,461 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/kcarretto/realm/tavern/ent/beacon" + "github.com/kcarretto/realm/tavern/ent/tag" + "github.com/kcarretto/realm/tavern/ent/task" +) + +// BeaconCreate is the builder for creating a Beacon entity. +type BeaconCreate struct { + config + mutation *BeaconMutation + hooks []Hook +} + +// SetName sets the "name" field. +func (bc *BeaconCreate) SetName(s string) *BeaconCreate { + bc.mutation.SetName(s) + return bc +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableName(s *string) *BeaconCreate { + if s != nil { + bc.SetName(*s) + } + return bc +} + +// SetPrincipal sets the "principal" field. +func (bc *BeaconCreate) SetPrincipal(s string) *BeaconCreate { + bc.mutation.SetPrincipal(s) + return bc +} + +// SetNillablePrincipal sets the "principal" field if the given value is not nil. +func (bc *BeaconCreate) SetNillablePrincipal(s *string) *BeaconCreate { + if s != nil { + bc.SetPrincipal(*s) + } + return bc +} + +// SetHostname sets the "hostname" field. +func (bc *BeaconCreate) SetHostname(s string) *BeaconCreate { + bc.mutation.SetHostname(s) + return bc +} + +// SetNillableHostname sets the "hostname" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableHostname(s *string) *BeaconCreate { + if s != nil { + bc.SetHostname(*s) + } + return bc +} + +// SetIdentifier sets the "identifier" field. +func (bc *BeaconCreate) SetIdentifier(s string) *BeaconCreate { + bc.mutation.SetIdentifier(s) + return bc +} + +// SetNillableIdentifier sets the "identifier" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableIdentifier(s *string) *BeaconCreate { + if s != nil { + bc.SetIdentifier(*s) + } + return bc +} + +// SetAgentIdentifier sets the "agent_identifier" field. +func (bc *BeaconCreate) SetAgentIdentifier(s string) *BeaconCreate { + bc.mutation.SetAgentIdentifier(s) + return bc +} + +// SetNillableAgentIdentifier sets the "agent_identifier" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableAgentIdentifier(s *string) *BeaconCreate { + if s != nil { + bc.SetAgentIdentifier(*s) + } + return bc +} + +// SetHostIdentifier sets the "host_identifier" field. +func (bc *BeaconCreate) SetHostIdentifier(s string) *BeaconCreate { + bc.mutation.SetHostIdentifier(s) + return bc +} + +// SetNillableHostIdentifier sets the "host_identifier" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableHostIdentifier(s *string) *BeaconCreate { + if s != nil { + bc.SetHostIdentifier(*s) + } + return bc +} + +// SetHostPrimaryIP sets the "host_primary_ip" field. +func (bc *BeaconCreate) SetHostPrimaryIP(s string) *BeaconCreate { + bc.mutation.SetHostPrimaryIP(s) + return bc +} + +// SetNillableHostPrimaryIP sets the "host_primary_ip" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableHostPrimaryIP(s *string) *BeaconCreate { + if s != nil { + bc.SetHostPrimaryIP(*s) + } + return bc +} + +// SetHostPlatform sets the "host_platform" field. +func (bc *BeaconCreate) SetHostPlatform(bp beacon.HostPlatform) *BeaconCreate { + bc.mutation.SetHostPlatform(bp) + return bc +} + +// SetNillableHostPlatform sets the "host_platform" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableHostPlatform(bp *beacon.HostPlatform) *BeaconCreate { + if bp != nil { + bc.SetHostPlatform(*bp) + } + return bc +} + +// SetLastSeenAt sets the "last_seen_at" field. +func (bc *BeaconCreate) SetLastSeenAt(t time.Time) *BeaconCreate { + bc.mutation.SetLastSeenAt(t) + return bc +} + +// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableLastSeenAt(t *time.Time) *BeaconCreate { + if t != nil { + bc.SetLastSeenAt(*t) + } + return bc +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (bc *BeaconCreate) AddTagIDs(ids ...int) *BeaconCreate { + bc.mutation.AddTagIDs(ids...) + return bc +} + +// AddTags adds the "tags" edges to the Tag entity. +func (bc *BeaconCreate) AddTags(t ...*Tag) *BeaconCreate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bc.AddTagIDs(ids...) +} + +// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. +func (bc *BeaconCreate) AddTaskIDs(ids ...int) *BeaconCreate { + bc.mutation.AddTaskIDs(ids...) + return bc +} + +// AddTasks adds the "tasks" edges to the Task entity. +func (bc *BeaconCreate) AddTasks(t ...*Task) *BeaconCreate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bc.AddTaskIDs(ids...) +} + +// Mutation returns the BeaconMutation object of the builder. +func (bc *BeaconCreate) Mutation() *BeaconMutation { + return bc.mutation +} + +// Save creates the Beacon in the database. +func (bc *BeaconCreate) Save(ctx context.Context) (*Beacon, error) { + bc.defaults() + return withHooks[*Beacon, BeaconMutation](ctx, bc.sqlSave, bc.mutation, bc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (bc *BeaconCreate) SaveX(ctx context.Context) *Beacon { + v, err := bc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bc *BeaconCreate) Exec(ctx context.Context) error { + _, err := bc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bc *BeaconCreate) ExecX(ctx context.Context) { + if err := bc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bc *BeaconCreate) defaults() { + if _, ok := bc.mutation.Name(); !ok { + v := beacon.DefaultName() + bc.mutation.SetName(v) + } + if _, ok := bc.mutation.Identifier(); !ok { + v := beacon.DefaultIdentifier() + bc.mutation.SetIdentifier(v) + } + if _, ok := bc.mutation.HostPlatform(); !ok { + v := beacon.DefaultHostPlatform + bc.mutation.SetHostPlatform(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (bc *BeaconCreate) check() error { + if _, ok := bc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Beacon.name"`)} + } + if v, ok := bc.mutation.Name(); ok { + if err := beacon.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Beacon.name": %w`, err)} + } + } + if v, ok := bc.mutation.Principal(); ok { + if err := beacon.PrincipalValidator(v); err != nil { + return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Beacon.principal": %w`, err)} + } + } + if v, ok := bc.mutation.Hostname(); ok { + if err := beacon.HostnameValidator(v); err != nil { + return &ValidationError{Name: "hostname", err: fmt.Errorf(`ent: validator failed for field "Beacon.hostname": %w`, err)} + } + } + if _, ok := bc.mutation.Identifier(); !ok { + return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "Beacon.identifier"`)} + } + if v, ok := bc.mutation.Identifier(); ok { + if err := beacon.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.identifier": %w`, err)} + } + } + if v, ok := bc.mutation.AgentIdentifier(); ok { + if err := beacon.AgentIdentifierValidator(v); err != nil { + return &ValidationError{Name: "agent_identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.agent_identifier": %w`, err)} + } + } + if v, ok := bc.mutation.HostIdentifier(); ok { + if err := beacon.HostIdentifierValidator(v); err != nil { + return &ValidationError{Name: "host_identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.host_identifier": %w`, err)} + } + } + if _, ok := bc.mutation.HostPlatform(); !ok { + return &ValidationError{Name: "host_platform", err: errors.New(`ent: missing required field "Beacon.host_platform"`)} + } + if v, ok := bc.mutation.HostPlatform(); ok { + if err := beacon.HostPlatformValidator(v); err != nil { + return &ValidationError{Name: "host_platform", err: fmt.Errorf(`ent: validator failed for field "Beacon.host_platform": %w`, err)} + } + } + return nil +} + +func (bc *BeaconCreate) sqlSave(ctx context.Context) (*Beacon, error) { + if err := bc.check(); err != nil { + return nil, err + } + _node, _spec := bc.createSpec() + if err := sqlgraph.CreateNode(ctx, bc.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) + bc.mutation.id = &_node.ID + bc.mutation.done = true + return _node, nil +} + +func (bc *BeaconCreate) createSpec() (*Beacon, *sqlgraph.CreateSpec) { + var ( + _node = &Beacon{config: bc.config} + _spec = sqlgraph.NewCreateSpec(beacon.Table, sqlgraph.NewFieldSpec(beacon.FieldID, field.TypeInt)) + ) + if value, ok := bc.mutation.Name(); ok { + _spec.SetField(beacon.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := bc.mutation.Principal(); ok { + _spec.SetField(beacon.FieldPrincipal, field.TypeString, value) + _node.Principal = value + } + if value, ok := bc.mutation.Hostname(); ok { + _spec.SetField(beacon.FieldHostname, field.TypeString, value) + _node.Hostname = value + } + if value, ok := bc.mutation.Identifier(); ok { + _spec.SetField(beacon.FieldIdentifier, field.TypeString, value) + _node.Identifier = value + } + if value, ok := bc.mutation.AgentIdentifier(); ok { + _spec.SetField(beacon.FieldAgentIdentifier, field.TypeString, value) + _node.AgentIdentifier = value + } + if value, ok := bc.mutation.HostIdentifier(); ok { + _spec.SetField(beacon.FieldHostIdentifier, field.TypeString, value) + _node.HostIdentifier = value + } + if value, ok := bc.mutation.HostPrimaryIP(); ok { + _spec.SetField(beacon.FieldHostPrimaryIP, field.TypeString, value) + _node.HostPrimaryIP = value + } + if value, ok := bc.mutation.HostPlatform(); ok { + _spec.SetField(beacon.FieldHostPlatform, field.TypeEnum, value) + _node.HostPlatform = value + } + if value, ok := bc.mutation.LastSeenAt(); ok { + _spec.SetField(beacon.FieldLastSeenAt, field.TypeTime, value) + _node.LastSeenAt = value + } + if nodes := bc.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: beacon.TagsTable, + Columns: beacon.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tag.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := bc.mutation.TasksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: beacon.TasksTable, + Columns: []string{beacon.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// BeaconCreateBulk is the builder for creating many Beacon entities in bulk. +type BeaconCreateBulk struct { + config + builders []*BeaconCreate +} + +// Save creates the Beacon entities in the database. +func (bcb *BeaconCreateBulk) Save(ctx context.Context) ([]*Beacon, error) { + specs := make([]*sqlgraph.CreateSpec, len(bcb.builders)) + nodes := make([]*Beacon, len(bcb.builders)) + mutators := make([]Mutator, len(bcb.builders)) + for i := range bcb.builders { + func(i int, root context.Context) { + builder := bcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*BeaconMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, bcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, bcb.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, bcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (bcb *BeaconCreateBulk) SaveX(ctx context.Context) []*Beacon { + v, err := bcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bcb *BeaconCreateBulk) Exec(ctx context.Context) error { + _, err := bcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bcb *BeaconCreateBulk) ExecX(ctx context.Context) { + if err := bcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/ent/beacon_delete.go b/tavern/ent/beacon_delete.go new file mode 100644 index 000000000..b7b5690a8 --- /dev/null +++ b/tavern/ent/beacon_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" + "github.com/kcarretto/realm/tavern/ent/beacon" + "github.com/kcarretto/realm/tavern/ent/predicate" +) + +// BeaconDelete is the builder for deleting a Beacon entity. +type BeaconDelete struct { + config + hooks []Hook + mutation *BeaconMutation +} + +// Where appends a list predicates to the BeaconDelete builder. +func (bd *BeaconDelete) Where(ps ...predicate.Beacon) *BeaconDelete { + bd.mutation.Where(ps...) + return bd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (bd *BeaconDelete) Exec(ctx context.Context) (int, error) { + return withHooks[int, BeaconMutation](ctx, bd.sqlExec, bd.mutation, bd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (bd *BeaconDelete) ExecX(ctx context.Context) int { + n, err := bd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (bd *BeaconDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(beacon.Table, sqlgraph.NewFieldSpec(beacon.FieldID, field.TypeInt)) + if ps := bd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + bd.mutation.done = true + return affected, err +} + +// BeaconDeleteOne is the builder for deleting a single Beacon entity. +type BeaconDeleteOne struct { + bd *BeaconDelete +} + +// Where appends a list predicates to the BeaconDelete builder. +func (bdo *BeaconDeleteOne) Where(ps ...predicate.Beacon) *BeaconDeleteOne { + bdo.bd.mutation.Where(ps...) + return bdo +} + +// Exec executes the deletion query. +func (bdo *BeaconDeleteOne) Exec(ctx context.Context) error { + n, err := bdo.bd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{beacon.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (bdo *BeaconDeleteOne) ExecX(ctx context.Context) { + if err := bdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/ent/beacon_query.go b/tavern/ent/beacon_query.go new file mode 100644 index 000000000..a6332bf6c --- /dev/null +++ b/tavern/ent/beacon_query.go @@ -0,0 +1,768 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/kcarretto/realm/tavern/ent/beacon" + "github.com/kcarretto/realm/tavern/ent/predicate" + "github.com/kcarretto/realm/tavern/ent/tag" + "github.com/kcarretto/realm/tavern/ent/task" +) + +// BeaconQuery is the builder for querying Beacon entities. +type BeaconQuery struct { + config + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Beacon + withTags *TagQuery + withTasks *TaskQuery + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Beacon) error + withNamedTags map[string]*TagQuery + withNamedTasks map[string]*TaskQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the BeaconQuery builder. +func (bq *BeaconQuery) Where(ps ...predicate.Beacon) *BeaconQuery { + bq.predicates = append(bq.predicates, ps...) + return bq +} + +// Limit the number of records to be returned by this query. +func (bq *BeaconQuery) Limit(limit int) *BeaconQuery { + bq.ctx.Limit = &limit + return bq +} + +// Offset to start from. +func (bq *BeaconQuery) Offset(offset int) *BeaconQuery { + bq.ctx.Offset = &offset + return bq +} + +// 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 (bq *BeaconQuery) Unique(unique bool) *BeaconQuery { + bq.ctx.Unique = &unique + return bq +} + +// Order specifies how the records should be ordered. +func (bq *BeaconQuery) Order(o ...OrderFunc) *BeaconQuery { + bq.order = append(bq.order, o...) + return bq +} + +// QueryTags chains the current query on the "tags" edge. +func (bq *BeaconQuery) QueryTags() *TagQuery { + query := (&TagClient{config: bq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(beacon.Table, beacon.FieldID, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, beacon.TagsTable, beacon.TagsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(bq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTasks chains the current query on the "tasks" edge. +func (bq *BeaconQuery) QueryTasks() *TaskQuery { + query := (&TaskClient{config: bq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(beacon.Table, beacon.FieldID, selector), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, beacon.TasksTable, beacon.TasksColumn), + ) + fromU = sqlgraph.SetNeighbors(bq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Beacon entity from the query. +// Returns a *NotFoundError when no Beacon was found. +func (bq *BeaconQuery) First(ctx context.Context) (*Beacon, error) { + nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{beacon.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (bq *BeaconQuery) FirstX(ctx context.Context) *Beacon { + node, err := bq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Beacon ID from the query. +// Returns a *NotFoundError when no Beacon ID was found. +func (bq *BeaconQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{beacon.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (bq *BeaconQuery) FirstIDX(ctx context.Context) int { + id, err := bq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Beacon entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Beacon entity is found. +// Returns a *NotFoundError when no Beacon entities are found. +func (bq *BeaconQuery) Only(ctx context.Context) (*Beacon, error) { + nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{beacon.Label} + default: + return nil, &NotSingularError{beacon.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (bq *BeaconQuery) OnlyX(ctx context.Context) *Beacon { + node, err := bq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Beacon ID in the query. +// Returns a *NotSingularError when more than one Beacon ID is found. +// Returns a *NotFoundError when no entities are found. +func (bq *BeaconQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{beacon.Label} + default: + err = &NotSingularError{beacon.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (bq *BeaconQuery) OnlyIDX(ctx context.Context) int { + id, err := bq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Beacons. +func (bq *BeaconQuery) All(ctx context.Context) ([]*Beacon, error) { + ctx = setContextOp(ctx, bq.ctx, "All") + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Beacon, *BeaconQuery]() + return withInterceptors[[]*Beacon](ctx, bq, qr, bq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (bq *BeaconQuery) AllX(ctx context.Context) []*Beacon { + nodes, err := bq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Beacon IDs. +func (bq *BeaconQuery) IDs(ctx context.Context) (ids []int, err error) { + if bq.ctx.Unique == nil && bq.path != nil { + bq.Unique(true) + } + ctx = setContextOp(ctx, bq.ctx, "IDs") + if err = bq.Select(beacon.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (bq *BeaconQuery) IDsX(ctx context.Context) []int { + ids, err := bq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (bq *BeaconQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, bq.ctx, "Count") + if err := bq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, bq, querierCount[*BeaconQuery](), bq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (bq *BeaconQuery) CountX(ctx context.Context) int { + count, err := bq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (bq *BeaconQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, bq.ctx, "Exist") + switch _, err := bq.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 (bq *BeaconQuery) ExistX(ctx context.Context) bool { + exist, err := bq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the BeaconQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (bq *BeaconQuery) Clone() *BeaconQuery { + if bq == nil { + return nil + } + return &BeaconQuery{ + config: bq.config, + ctx: bq.ctx.Clone(), + order: append([]OrderFunc{}, bq.order...), + inters: append([]Interceptor{}, bq.inters...), + predicates: append([]predicate.Beacon{}, bq.predicates...), + withTags: bq.withTags.Clone(), + withTasks: bq.withTasks.Clone(), + // clone intermediate query. + sql: bq.sql.Clone(), + path: bq.path, + } +} + +// WithTags tells the query-builder to eager-load the nodes that are connected to +// the "tags" edge. The optional arguments are used to configure the query builder of the edge. +func (bq *BeaconQuery) WithTags(opts ...func(*TagQuery)) *BeaconQuery { + query := (&TagClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + bq.withTags = query + return bq +} + +// WithTasks tells the query-builder to eager-load the nodes that are connected to +// the "tasks" edge. The optional arguments are used to configure the query builder of the edge. +func (bq *BeaconQuery) WithTasks(opts ...func(*TaskQuery)) *BeaconQuery { + query := (&TaskClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + bq.withTasks = query + return bq +} + +// 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 { +// Name string `json:"name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Beacon.Query(). +// GroupBy(beacon.FieldName). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (bq *BeaconQuery) GroupBy(field string, fields ...string) *BeaconGroupBy { + bq.ctx.Fields = append([]string{field}, fields...) + grbuild := &BeaconGroupBy{build: bq} + grbuild.flds = &bq.ctx.Fields + grbuild.label = beacon.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 { +// Name string `json:"name,omitempty"` +// } +// +// client.Beacon.Query(). +// Select(beacon.FieldName). +// Scan(ctx, &v) +func (bq *BeaconQuery) Select(fields ...string) *BeaconSelect { + bq.ctx.Fields = append(bq.ctx.Fields, fields...) + sbuild := &BeaconSelect{BeaconQuery: bq} + sbuild.label = beacon.Label + sbuild.flds, sbuild.scan = &bq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a BeaconSelect configured with the given aggregations. +func (bq *BeaconQuery) Aggregate(fns ...AggregateFunc) *BeaconSelect { + return bq.Select().Aggregate(fns...) +} + +func (bq *BeaconQuery) prepareQuery(ctx context.Context) error { + for _, inter := range bq.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, bq); err != nil { + return err + } + } + } + for _, f := range bq.ctx.Fields { + if !beacon.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if bq.path != nil { + prev, err := bq.path(ctx) + if err != nil { + return err + } + bq.sql = prev + } + return nil +} + +func (bq *BeaconQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Beacon, error) { + var ( + nodes = []*Beacon{} + _spec = bq.querySpec() + loadedTypes = [2]bool{ + bq.withTags != nil, + bq.withTasks != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Beacon).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Beacon{config: bq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := bq.withTags; query != nil { + if err := bq.loadTags(ctx, query, nodes, + func(n *Beacon) { n.Edges.Tags = []*Tag{} }, + func(n *Beacon, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { + return nil, err + } + } + if query := bq.withTasks; query != nil { + if err := bq.loadTasks(ctx, query, nodes, + func(n *Beacon) { n.Edges.Tasks = []*Task{} }, + func(n *Beacon, e *Task) { n.Edges.Tasks = append(n.Edges.Tasks, e) }); err != nil { + return nil, err + } + } + for name, query := range bq.withNamedTags { + if err := bq.loadTags(ctx, query, nodes, + func(n *Beacon) { n.appendNamedTags(name) }, + func(n *Beacon, e *Tag) { n.appendNamedTags(name, e) }); err != nil { + return nil, err + } + } + for name, query := range bq.withNamedTasks { + if err := bq.loadTasks(ctx, query, nodes, + func(n *Beacon) { n.appendNamedTasks(name) }, + func(n *Beacon, e *Task) { n.appendNamedTasks(name, e) }); err != nil { + return nil, err + } + } + for i := range bq.loadTotal { + if err := bq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (bq *BeaconQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Beacon, init func(*Beacon), assign func(*Beacon, *Tag)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int]*Beacon) + nids := make(map[int]map[*Beacon]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(beacon.TagsTable) + s.Join(joinT).On(s.C(tag.FieldID), joinT.C(beacon.TagsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(beacon.TagsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(beacon.TagsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := int(values[0].(*sql.NullInt64).Int64) + inValue := int(values[1].(*sql.NullInt64).Int64) + if nids[inValue] == nil { + nids[inValue] = map[*Beacon]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Tag](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "tags" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (bq *BeaconQuery) loadTasks(ctx context.Context, query *TaskQuery, nodes []*Beacon, init func(*Beacon), assign func(*Beacon, *Task)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Beacon) + 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.Task(func(s *sql.Selector) { + s.Where(sql.InValues(beacon.TasksColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.task_beacon + if fk == nil { + return fmt.Errorf(`foreign-key "task_beacon" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected foreign-key "task_beacon" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (bq *BeaconQuery) sqlCount(ctx context.Context) (int, error) { + _spec := bq.querySpec() + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + _spec.Node.Columns = bq.ctx.Fields + if len(bq.ctx.Fields) > 0 { + _spec.Unique = bq.ctx.Unique != nil && *bq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, bq.driver, _spec) +} + +func (bq *BeaconQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(beacon.Table, beacon.Columns, sqlgraph.NewFieldSpec(beacon.FieldID, field.TypeInt)) + _spec.From = bq.sql + if unique := bq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if bq.path != nil { + _spec.Unique = true + } + if fields := bq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, beacon.FieldID) + for i := range fields { + if fields[i] != beacon.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := bq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := bq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := bq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := bq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (bq *BeaconQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(bq.driver.Dialect()) + t1 := builder.Table(beacon.Table) + columns := bq.ctx.Fields + if len(columns) == 0 { + columns = beacon.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if bq.sql != nil { + selector = bq.sql + selector.Select(selector.Columns(columns...)...) + } + if bq.ctx.Unique != nil && *bq.ctx.Unique { + selector.Distinct() + } + for _, p := range bq.predicates { + p(selector) + } + for _, p := range bq.order { + p(selector) + } + if offset := bq.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 := bq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// WithNamedTags tells the query-builder to eager-load the nodes that are connected to the "tags" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (bq *BeaconQuery) WithNamedTags(name string, opts ...func(*TagQuery)) *BeaconQuery { + query := (&TagClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + if bq.withNamedTags == nil { + bq.withNamedTags = make(map[string]*TagQuery) + } + bq.withNamedTags[name] = query + return bq +} + +// WithNamedTasks tells the query-builder to eager-load the nodes that are connected to the "tasks" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (bq *BeaconQuery) WithNamedTasks(name string, opts ...func(*TaskQuery)) *BeaconQuery { + query := (&TaskClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + if bq.withNamedTasks == nil { + bq.withNamedTasks = make(map[string]*TaskQuery) + } + bq.withNamedTasks[name] = query + return bq +} + +// BeaconGroupBy is the group-by builder for Beacon entities. +type BeaconGroupBy struct { + selector + build *BeaconQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (bgb *BeaconGroupBy) Aggregate(fns ...AggregateFunc) *BeaconGroupBy { + bgb.fns = append(bgb.fns, fns...) + return bgb +} + +// Scan applies the selector query and scans the result into the given value. +func (bgb *BeaconGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bgb.build.ctx, "GroupBy") + if err := bgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BeaconQuery, *BeaconGroupBy](ctx, bgb.build, bgb, bgb.build.inters, v) +} + +func (bgb *BeaconGroupBy) sqlScan(ctx context.Context, root *BeaconQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(bgb.fns)) + for _, fn := range bgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*bgb.flds)+len(bgb.fns)) + for _, f := range *bgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*bgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// BeaconSelect is the builder for selecting fields of Beacon entities. +type BeaconSelect struct { + *BeaconQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (bs *BeaconSelect) Aggregate(fns ...AggregateFunc) *BeaconSelect { + bs.fns = append(bs.fns, fns...) + return bs +} + +// Scan applies the selector query and scans the result into the given value. +func (bs *BeaconSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bs.ctx, "Select") + if err := bs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BeaconQuery, *BeaconSelect](ctx, bs.BeaconQuery, bs, bs.inters, v) +} + +func (bs *BeaconSelect) sqlScan(ctx context.Context, root *BeaconQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(bs.fns)) + for _, fn := range bs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*bs.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 := bs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/ent/beacon_update.go b/tavern/ent/beacon_update.go new file mode 100644 index 000000000..988503faa --- /dev/null +++ b/tavern/ent/beacon_update.go @@ -0,0 +1,1038 @@ +// 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" + "github.com/kcarretto/realm/tavern/ent/beacon" + "github.com/kcarretto/realm/tavern/ent/predicate" + "github.com/kcarretto/realm/tavern/ent/tag" + "github.com/kcarretto/realm/tavern/ent/task" +) + +// BeaconUpdate is the builder for updating Beacon entities. +type BeaconUpdate struct { + config + hooks []Hook + mutation *BeaconMutation +} + +// Where appends a list predicates to the BeaconUpdate builder. +func (bu *BeaconUpdate) Where(ps ...predicate.Beacon) *BeaconUpdate { + bu.mutation.Where(ps...) + return bu +} + +// SetName sets the "name" field. +func (bu *BeaconUpdate) SetName(s string) *BeaconUpdate { + bu.mutation.SetName(s) + return bu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableName(s *string) *BeaconUpdate { + if s != nil { + bu.SetName(*s) + } + return bu +} + +// SetPrincipal sets the "principal" field. +func (bu *BeaconUpdate) SetPrincipal(s string) *BeaconUpdate { + bu.mutation.SetPrincipal(s) + return bu +} + +// SetNillablePrincipal sets the "principal" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillablePrincipal(s *string) *BeaconUpdate { + if s != nil { + bu.SetPrincipal(*s) + } + return bu +} + +// ClearPrincipal clears the value of the "principal" field. +func (bu *BeaconUpdate) ClearPrincipal() *BeaconUpdate { + bu.mutation.ClearPrincipal() + return bu +} + +// SetHostname sets the "hostname" field. +func (bu *BeaconUpdate) SetHostname(s string) *BeaconUpdate { + bu.mutation.SetHostname(s) + return bu +} + +// SetNillableHostname sets the "hostname" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableHostname(s *string) *BeaconUpdate { + if s != nil { + bu.SetHostname(*s) + } + return bu +} + +// ClearHostname clears the value of the "hostname" field. +func (bu *BeaconUpdate) ClearHostname() *BeaconUpdate { + bu.mutation.ClearHostname() + return bu +} + +// SetIdentifier sets the "identifier" field. +func (bu *BeaconUpdate) SetIdentifier(s string) *BeaconUpdate { + bu.mutation.SetIdentifier(s) + return bu +} + +// SetNillableIdentifier sets the "identifier" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableIdentifier(s *string) *BeaconUpdate { + if s != nil { + bu.SetIdentifier(*s) + } + return bu +} + +// SetAgentIdentifier sets the "agent_identifier" field. +func (bu *BeaconUpdate) SetAgentIdentifier(s string) *BeaconUpdate { + bu.mutation.SetAgentIdentifier(s) + return bu +} + +// SetNillableAgentIdentifier sets the "agent_identifier" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableAgentIdentifier(s *string) *BeaconUpdate { + if s != nil { + bu.SetAgentIdentifier(*s) + } + return bu +} + +// ClearAgentIdentifier clears the value of the "agent_identifier" field. +func (bu *BeaconUpdate) ClearAgentIdentifier() *BeaconUpdate { + bu.mutation.ClearAgentIdentifier() + return bu +} + +// SetHostIdentifier sets the "host_identifier" field. +func (bu *BeaconUpdate) SetHostIdentifier(s string) *BeaconUpdate { + bu.mutation.SetHostIdentifier(s) + return bu +} + +// SetNillableHostIdentifier sets the "host_identifier" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableHostIdentifier(s *string) *BeaconUpdate { + if s != nil { + bu.SetHostIdentifier(*s) + } + return bu +} + +// ClearHostIdentifier clears the value of the "host_identifier" field. +func (bu *BeaconUpdate) ClearHostIdentifier() *BeaconUpdate { + bu.mutation.ClearHostIdentifier() + return bu +} + +// SetHostPrimaryIP sets the "host_primary_ip" field. +func (bu *BeaconUpdate) SetHostPrimaryIP(s string) *BeaconUpdate { + bu.mutation.SetHostPrimaryIP(s) + return bu +} + +// SetNillableHostPrimaryIP sets the "host_primary_ip" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableHostPrimaryIP(s *string) *BeaconUpdate { + if s != nil { + bu.SetHostPrimaryIP(*s) + } + return bu +} + +// ClearHostPrimaryIP clears the value of the "host_primary_ip" field. +func (bu *BeaconUpdate) ClearHostPrimaryIP() *BeaconUpdate { + bu.mutation.ClearHostPrimaryIP() + return bu +} + +// SetHostPlatform sets the "host_platform" field. +func (bu *BeaconUpdate) SetHostPlatform(bp beacon.HostPlatform) *BeaconUpdate { + bu.mutation.SetHostPlatform(bp) + return bu +} + +// SetNillableHostPlatform sets the "host_platform" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableHostPlatform(bp *beacon.HostPlatform) *BeaconUpdate { + if bp != nil { + bu.SetHostPlatform(*bp) + } + return bu +} + +// SetLastSeenAt sets the "last_seen_at" field. +func (bu *BeaconUpdate) SetLastSeenAt(t time.Time) *BeaconUpdate { + bu.mutation.SetLastSeenAt(t) + return bu +} + +// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. +func (bu *BeaconUpdate) SetNillableLastSeenAt(t *time.Time) *BeaconUpdate { + if t != nil { + bu.SetLastSeenAt(*t) + } + return bu +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (bu *BeaconUpdate) ClearLastSeenAt() *BeaconUpdate { + bu.mutation.ClearLastSeenAt() + return bu +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (bu *BeaconUpdate) AddTagIDs(ids ...int) *BeaconUpdate { + bu.mutation.AddTagIDs(ids...) + return bu +} + +// AddTags adds the "tags" edges to the Tag entity. +func (bu *BeaconUpdate) AddTags(t ...*Tag) *BeaconUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bu.AddTagIDs(ids...) +} + +// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. +func (bu *BeaconUpdate) AddTaskIDs(ids ...int) *BeaconUpdate { + bu.mutation.AddTaskIDs(ids...) + return bu +} + +// AddTasks adds the "tasks" edges to the Task entity. +func (bu *BeaconUpdate) AddTasks(t ...*Task) *BeaconUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bu.AddTaskIDs(ids...) +} + +// Mutation returns the BeaconMutation object of the builder. +func (bu *BeaconUpdate) Mutation() *BeaconMutation { + return bu.mutation +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (bu *BeaconUpdate) ClearTags() *BeaconUpdate { + bu.mutation.ClearTags() + return bu +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (bu *BeaconUpdate) RemoveTagIDs(ids ...int) *BeaconUpdate { + bu.mutation.RemoveTagIDs(ids...) + return bu +} + +// RemoveTags removes "tags" edges to Tag entities. +func (bu *BeaconUpdate) RemoveTags(t ...*Tag) *BeaconUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bu.RemoveTagIDs(ids...) +} + +// ClearTasks clears all "tasks" edges to the Task entity. +func (bu *BeaconUpdate) ClearTasks() *BeaconUpdate { + bu.mutation.ClearTasks() + return bu +} + +// RemoveTaskIDs removes the "tasks" edge to Task entities by IDs. +func (bu *BeaconUpdate) RemoveTaskIDs(ids ...int) *BeaconUpdate { + bu.mutation.RemoveTaskIDs(ids...) + return bu +} + +// RemoveTasks removes "tasks" edges to Task entities. +func (bu *BeaconUpdate) RemoveTasks(t ...*Task) *BeaconUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bu.RemoveTaskIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (bu *BeaconUpdate) Save(ctx context.Context) (int, error) { + return withHooks[int, BeaconMutation](ctx, bu.sqlSave, bu.mutation, bu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (bu *BeaconUpdate) SaveX(ctx context.Context) int { + affected, err := bu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (bu *BeaconUpdate) Exec(ctx context.Context) error { + _, err := bu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bu *BeaconUpdate) ExecX(ctx context.Context) { + if err := bu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (bu *BeaconUpdate) check() error { + if v, ok := bu.mutation.Name(); ok { + if err := beacon.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Beacon.name": %w`, err)} + } + } + if v, ok := bu.mutation.Principal(); ok { + if err := beacon.PrincipalValidator(v); err != nil { + return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Beacon.principal": %w`, err)} + } + } + if v, ok := bu.mutation.Hostname(); ok { + if err := beacon.HostnameValidator(v); err != nil { + return &ValidationError{Name: "hostname", err: fmt.Errorf(`ent: validator failed for field "Beacon.hostname": %w`, err)} + } + } + if v, ok := bu.mutation.Identifier(); ok { + if err := beacon.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.identifier": %w`, err)} + } + } + if v, ok := bu.mutation.AgentIdentifier(); ok { + if err := beacon.AgentIdentifierValidator(v); err != nil { + return &ValidationError{Name: "agent_identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.agent_identifier": %w`, err)} + } + } + if v, ok := bu.mutation.HostIdentifier(); ok { + if err := beacon.HostIdentifierValidator(v); err != nil { + return &ValidationError{Name: "host_identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.host_identifier": %w`, err)} + } + } + if v, ok := bu.mutation.HostPlatform(); ok { + if err := beacon.HostPlatformValidator(v); err != nil { + return &ValidationError{Name: "host_platform", err: fmt.Errorf(`ent: validator failed for field "Beacon.host_platform": %w`, err)} + } + } + return nil +} + +func (bu *BeaconUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := bu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(beacon.Table, beacon.Columns, sqlgraph.NewFieldSpec(beacon.FieldID, field.TypeInt)) + if ps := bu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := bu.mutation.Name(); ok { + _spec.SetField(beacon.FieldName, field.TypeString, value) + } + if value, ok := bu.mutation.Principal(); ok { + _spec.SetField(beacon.FieldPrincipal, field.TypeString, value) + } + if bu.mutation.PrincipalCleared() { + _spec.ClearField(beacon.FieldPrincipal, field.TypeString) + } + if value, ok := bu.mutation.Hostname(); ok { + _spec.SetField(beacon.FieldHostname, field.TypeString, value) + } + if bu.mutation.HostnameCleared() { + _spec.ClearField(beacon.FieldHostname, field.TypeString) + } + if value, ok := bu.mutation.Identifier(); ok { + _spec.SetField(beacon.FieldIdentifier, field.TypeString, value) + } + if value, ok := bu.mutation.AgentIdentifier(); ok { + _spec.SetField(beacon.FieldAgentIdentifier, field.TypeString, value) + } + if bu.mutation.AgentIdentifierCleared() { + _spec.ClearField(beacon.FieldAgentIdentifier, field.TypeString) + } + if value, ok := bu.mutation.HostIdentifier(); ok { + _spec.SetField(beacon.FieldHostIdentifier, field.TypeString, value) + } + if bu.mutation.HostIdentifierCleared() { + _spec.ClearField(beacon.FieldHostIdentifier, field.TypeString) + } + if value, ok := bu.mutation.HostPrimaryIP(); ok { + _spec.SetField(beacon.FieldHostPrimaryIP, field.TypeString, value) + } + if bu.mutation.HostPrimaryIPCleared() { + _spec.ClearField(beacon.FieldHostPrimaryIP, field.TypeString) + } + if value, ok := bu.mutation.HostPlatform(); ok { + _spec.SetField(beacon.FieldHostPlatform, field.TypeEnum, value) + } + if value, ok := bu.mutation.LastSeenAt(); ok { + _spec.SetField(beacon.FieldLastSeenAt, field.TypeTime, value) + } + if bu.mutation.LastSeenAtCleared() { + _spec.ClearField(beacon.FieldLastSeenAt, field.TypeTime) + } + if bu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: beacon.TagsTable, + Columns: beacon.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tag.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.RemovedTagsIDs(); len(nodes) > 0 && !bu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: beacon.TagsTable, + Columns: beacon.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tag.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: beacon.TagsTable, + Columns: beacon.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tag.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if bu.mutation.TasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: beacon.TasksTable, + Columns: []string{beacon.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.RemovedTasksIDs(); len(nodes) > 0 && !bu.mutation.TasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: beacon.TasksTable, + Columns: []string{beacon.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.TasksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: beacon.TasksTable, + Columns: []string{beacon.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + 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, bu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{beacon.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + bu.mutation.done = true + return n, nil +} + +// BeaconUpdateOne is the builder for updating a single Beacon entity. +type BeaconUpdateOne struct { + config + fields []string + hooks []Hook + mutation *BeaconMutation +} + +// SetName sets the "name" field. +func (buo *BeaconUpdateOne) SetName(s string) *BeaconUpdateOne { + buo.mutation.SetName(s) + return buo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableName(s *string) *BeaconUpdateOne { + if s != nil { + buo.SetName(*s) + } + return buo +} + +// SetPrincipal sets the "principal" field. +func (buo *BeaconUpdateOne) SetPrincipal(s string) *BeaconUpdateOne { + buo.mutation.SetPrincipal(s) + return buo +} + +// SetNillablePrincipal sets the "principal" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillablePrincipal(s *string) *BeaconUpdateOne { + if s != nil { + buo.SetPrincipal(*s) + } + return buo +} + +// ClearPrincipal clears the value of the "principal" field. +func (buo *BeaconUpdateOne) ClearPrincipal() *BeaconUpdateOne { + buo.mutation.ClearPrincipal() + return buo +} + +// SetHostname sets the "hostname" field. +func (buo *BeaconUpdateOne) SetHostname(s string) *BeaconUpdateOne { + buo.mutation.SetHostname(s) + return buo +} + +// SetNillableHostname sets the "hostname" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableHostname(s *string) *BeaconUpdateOne { + if s != nil { + buo.SetHostname(*s) + } + return buo +} + +// ClearHostname clears the value of the "hostname" field. +func (buo *BeaconUpdateOne) ClearHostname() *BeaconUpdateOne { + buo.mutation.ClearHostname() + return buo +} + +// SetIdentifier sets the "identifier" field. +func (buo *BeaconUpdateOne) SetIdentifier(s string) *BeaconUpdateOne { + buo.mutation.SetIdentifier(s) + return buo +} + +// SetNillableIdentifier sets the "identifier" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableIdentifier(s *string) *BeaconUpdateOne { + if s != nil { + buo.SetIdentifier(*s) + } + return buo +} + +// SetAgentIdentifier sets the "agent_identifier" field. +func (buo *BeaconUpdateOne) SetAgentIdentifier(s string) *BeaconUpdateOne { + buo.mutation.SetAgentIdentifier(s) + return buo +} + +// SetNillableAgentIdentifier sets the "agent_identifier" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableAgentIdentifier(s *string) *BeaconUpdateOne { + if s != nil { + buo.SetAgentIdentifier(*s) + } + return buo +} + +// ClearAgentIdentifier clears the value of the "agent_identifier" field. +func (buo *BeaconUpdateOne) ClearAgentIdentifier() *BeaconUpdateOne { + buo.mutation.ClearAgentIdentifier() + return buo +} + +// SetHostIdentifier sets the "host_identifier" field. +func (buo *BeaconUpdateOne) SetHostIdentifier(s string) *BeaconUpdateOne { + buo.mutation.SetHostIdentifier(s) + return buo +} + +// SetNillableHostIdentifier sets the "host_identifier" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableHostIdentifier(s *string) *BeaconUpdateOne { + if s != nil { + buo.SetHostIdentifier(*s) + } + return buo +} + +// ClearHostIdentifier clears the value of the "host_identifier" field. +func (buo *BeaconUpdateOne) ClearHostIdentifier() *BeaconUpdateOne { + buo.mutation.ClearHostIdentifier() + return buo +} + +// SetHostPrimaryIP sets the "host_primary_ip" field. +func (buo *BeaconUpdateOne) SetHostPrimaryIP(s string) *BeaconUpdateOne { + buo.mutation.SetHostPrimaryIP(s) + return buo +} + +// SetNillableHostPrimaryIP sets the "host_primary_ip" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableHostPrimaryIP(s *string) *BeaconUpdateOne { + if s != nil { + buo.SetHostPrimaryIP(*s) + } + return buo +} + +// ClearHostPrimaryIP clears the value of the "host_primary_ip" field. +func (buo *BeaconUpdateOne) ClearHostPrimaryIP() *BeaconUpdateOne { + buo.mutation.ClearHostPrimaryIP() + return buo +} + +// SetHostPlatform sets the "host_platform" field. +func (buo *BeaconUpdateOne) SetHostPlatform(bp beacon.HostPlatform) *BeaconUpdateOne { + buo.mutation.SetHostPlatform(bp) + return buo +} + +// SetNillableHostPlatform sets the "host_platform" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableHostPlatform(bp *beacon.HostPlatform) *BeaconUpdateOne { + if bp != nil { + buo.SetHostPlatform(*bp) + } + return buo +} + +// SetLastSeenAt sets the "last_seen_at" field. +func (buo *BeaconUpdateOne) SetLastSeenAt(t time.Time) *BeaconUpdateOne { + buo.mutation.SetLastSeenAt(t) + return buo +} + +// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. +func (buo *BeaconUpdateOne) SetNillableLastSeenAt(t *time.Time) *BeaconUpdateOne { + if t != nil { + buo.SetLastSeenAt(*t) + } + return buo +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (buo *BeaconUpdateOne) ClearLastSeenAt() *BeaconUpdateOne { + buo.mutation.ClearLastSeenAt() + return buo +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (buo *BeaconUpdateOne) AddTagIDs(ids ...int) *BeaconUpdateOne { + buo.mutation.AddTagIDs(ids...) + return buo +} + +// AddTags adds the "tags" edges to the Tag entity. +func (buo *BeaconUpdateOne) AddTags(t ...*Tag) *BeaconUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return buo.AddTagIDs(ids...) +} + +// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. +func (buo *BeaconUpdateOne) AddTaskIDs(ids ...int) *BeaconUpdateOne { + buo.mutation.AddTaskIDs(ids...) + return buo +} + +// AddTasks adds the "tasks" edges to the Task entity. +func (buo *BeaconUpdateOne) AddTasks(t ...*Task) *BeaconUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return buo.AddTaskIDs(ids...) +} + +// Mutation returns the BeaconMutation object of the builder. +func (buo *BeaconUpdateOne) Mutation() *BeaconMutation { + return buo.mutation +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (buo *BeaconUpdateOne) ClearTags() *BeaconUpdateOne { + buo.mutation.ClearTags() + return buo +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (buo *BeaconUpdateOne) RemoveTagIDs(ids ...int) *BeaconUpdateOne { + buo.mutation.RemoveTagIDs(ids...) + return buo +} + +// RemoveTags removes "tags" edges to Tag entities. +func (buo *BeaconUpdateOne) RemoveTags(t ...*Tag) *BeaconUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return buo.RemoveTagIDs(ids...) +} + +// ClearTasks clears all "tasks" edges to the Task entity. +func (buo *BeaconUpdateOne) ClearTasks() *BeaconUpdateOne { + buo.mutation.ClearTasks() + return buo +} + +// RemoveTaskIDs removes the "tasks" edge to Task entities by IDs. +func (buo *BeaconUpdateOne) RemoveTaskIDs(ids ...int) *BeaconUpdateOne { + buo.mutation.RemoveTaskIDs(ids...) + return buo +} + +// RemoveTasks removes "tasks" edges to Task entities. +func (buo *BeaconUpdateOne) RemoveTasks(t ...*Task) *BeaconUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return buo.RemoveTaskIDs(ids...) +} + +// Where appends a list predicates to the BeaconUpdate builder. +func (buo *BeaconUpdateOne) Where(ps ...predicate.Beacon) *BeaconUpdateOne { + buo.mutation.Where(ps...) + return buo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (buo *BeaconUpdateOne) Select(field string, fields ...string) *BeaconUpdateOne { + buo.fields = append([]string{field}, fields...) + return buo +} + +// Save executes the query and returns the updated Beacon entity. +func (buo *BeaconUpdateOne) Save(ctx context.Context) (*Beacon, error) { + return withHooks[*Beacon, BeaconMutation](ctx, buo.sqlSave, buo.mutation, buo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (buo *BeaconUpdateOne) SaveX(ctx context.Context) *Beacon { + node, err := buo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (buo *BeaconUpdateOne) Exec(ctx context.Context) error { + _, err := buo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (buo *BeaconUpdateOne) ExecX(ctx context.Context) { + if err := buo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (buo *BeaconUpdateOne) check() error { + if v, ok := buo.mutation.Name(); ok { + if err := beacon.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Beacon.name": %w`, err)} + } + } + if v, ok := buo.mutation.Principal(); ok { + if err := beacon.PrincipalValidator(v); err != nil { + return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Beacon.principal": %w`, err)} + } + } + if v, ok := buo.mutation.Hostname(); ok { + if err := beacon.HostnameValidator(v); err != nil { + return &ValidationError{Name: "hostname", err: fmt.Errorf(`ent: validator failed for field "Beacon.hostname": %w`, err)} + } + } + if v, ok := buo.mutation.Identifier(); ok { + if err := beacon.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.identifier": %w`, err)} + } + } + if v, ok := buo.mutation.AgentIdentifier(); ok { + if err := beacon.AgentIdentifierValidator(v); err != nil { + return &ValidationError{Name: "agent_identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.agent_identifier": %w`, err)} + } + } + if v, ok := buo.mutation.HostIdentifier(); ok { + if err := beacon.HostIdentifierValidator(v); err != nil { + return &ValidationError{Name: "host_identifier", err: fmt.Errorf(`ent: validator failed for field "Beacon.host_identifier": %w`, err)} + } + } + if v, ok := buo.mutation.HostPlatform(); ok { + if err := beacon.HostPlatformValidator(v); err != nil { + return &ValidationError{Name: "host_platform", err: fmt.Errorf(`ent: validator failed for field "Beacon.host_platform": %w`, err)} + } + } + return nil +} + +func (buo *BeaconUpdateOne) sqlSave(ctx context.Context) (_node *Beacon, err error) { + if err := buo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(beacon.Table, beacon.Columns, sqlgraph.NewFieldSpec(beacon.FieldID, field.TypeInt)) + id, ok := buo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Beacon.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := buo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, beacon.FieldID) + for _, f := range fields { + if !beacon.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != beacon.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := buo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := buo.mutation.Name(); ok { + _spec.SetField(beacon.FieldName, field.TypeString, value) + } + if value, ok := buo.mutation.Principal(); ok { + _spec.SetField(beacon.FieldPrincipal, field.TypeString, value) + } + if buo.mutation.PrincipalCleared() { + _spec.ClearField(beacon.FieldPrincipal, field.TypeString) + } + if value, ok := buo.mutation.Hostname(); ok { + _spec.SetField(beacon.FieldHostname, field.TypeString, value) + } + if buo.mutation.HostnameCleared() { + _spec.ClearField(beacon.FieldHostname, field.TypeString) + } + if value, ok := buo.mutation.Identifier(); ok { + _spec.SetField(beacon.FieldIdentifier, field.TypeString, value) + } + if value, ok := buo.mutation.AgentIdentifier(); ok { + _spec.SetField(beacon.FieldAgentIdentifier, field.TypeString, value) + } + if buo.mutation.AgentIdentifierCleared() { + _spec.ClearField(beacon.FieldAgentIdentifier, field.TypeString) + } + if value, ok := buo.mutation.HostIdentifier(); ok { + _spec.SetField(beacon.FieldHostIdentifier, field.TypeString, value) + } + if buo.mutation.HostIdentifierCleared() { + _spec.ClearField(beacon.FieldHostIdentifier, field.TypeString) + } + if value, ok := buo.mutation.HostPrimaryIP(); ok { + _spec.SetField(beacon.FieldHostPrimaryIP, field.TypeString, value) + } + if buo.mutation.HostPrimaryIPCleared() { + _spec.ClearField(beacon.FieldHostPrimaryIP, field.TypeString) + } + if value, ok := buo.mutation.HostPlatform(); ok { + _spec.SetField(beacon.FieldHostPlatform, field.TypeEnum, value) + } + if value, ok := buo.mutation.LastSeenAt(); ok { + _spec.SetField(beacon.FieldLastSeenAt, field.TypeTime, value) + } + if buo.mutation.LastSeenAtCleared() { + _spec.ClearField(beacon.FieldLastSeenAt, field.TypeTime) + } + if buo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: beacon.TagsTable, + Columns: beacon.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tag.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.RemovedTagsIDs(); len(nodes) > 0 && !buo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: beacon.TagsTable, + Columns: beacon.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tag.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: beacon.TagsTable, + Columns: beacon.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tag.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if buo.mutation.TasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: beacon.TasksTable, + Columns: []string{beacon.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.RemovedTasksIDs(); len(nodes) > 0 && !buo.mutation.TasksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: beacon.TasksTable, + Columns: []string{beacon.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.TasksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: beacon.TasksTable, + Columns: []string{beacon.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Beacon{config: buo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{beacon.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + buo.mutation.done = true + return _node, nil +} diff --git a/tavern/ent/client.go b/tavern/ent/client.go index 3f7673d2e..311f23397 100644 --- a/tavern/ent/client.go +++ b/tavern/ent/client.go @@ -14,9 +14,9 @@ import ( "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" @@ -28,12 +28,12 @@ type Client struct { config // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema + // Beacon is the client for interacting with the Beacon builders. + Beacon *BeaconClient // File is the client for interacting with the File builders. File *FileClient - // Job is the client for interacting with the Job builders. - Job *JobClient - // Session is the client for interacting with the Session builders. - Session *SessionClient + // Quest is the client for interacting with the Quest builders. + Quest *QuestClient // Tag is the client for interacting with the Tag builders. Tag *TagClient // Task is the client for interacting with the Task builders. @@ -57,9 +57,9 @@ func NewClient(opts ...Option) *Client { func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) + c.Beacon = NewBeaconClient(c.config) c.File = NewFileClient(c.config) - c.Job = NewJobClient(c.config) - c.Session = NewSessionClient(c.config) + c.Quest = NewQuestClient(c.config) c.Tag = NewTagClient(c.config) c.Task = NewTaskClient(c.config) c.Tome = NewTomeClient(c.config) @@ -144,15 +144,15 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { cfg := c.config cfg.driver = tx return &Tx{ - ctx: ctx, - config: cfg, - File: NewFileClient(cfg), - Job: NewJobClient(cfg), - Session: NewSessionClient(cfg), - Tag: NewTagClient(cfg), - Task: NewTaskClient(cfg), - Tome: NewTomeClient(cfg), - User: NewUserClient(cfg), + ctx: ctx, + config: cfg, + Beacon: NewBeaconClient(cfg), + File: NewFileClient(cfg), + Quest: NewQuestClient(cfg), + Tag: NewTagClient(cfg), + Task: NewTaskClient(cfg), + Tome: NewTomeClient(cfg), + User: NewUserClient(cfg), }, nil } @@ -170,22 +170,22 @@ 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, - File: NewFileClient(cfg), - Job: NewJobClient(cfg), - Session: NewSessionClient(cfg), - Tag: NewTagClient(cfg), - Task: NewTaskClient(cfg), - Tome: NewTomeClient(cfg), - User: NewUserClient(cfg), + ctx: ctx, + config: cfg, + Beacon: NewBeaconClient(cfg), + File: NewFileClient(cfg), + Quest: NewQuestClient(cfg), + Tag: NewTagClient(cfg), + Task: NewTaskClient(cfg), + Tome: NewTomeClient(cfg), + User: NewUserClient(cfg), }, nil } // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). -// File. +// Beacon. // Query(). // Count(ctx) func (c *Client) Debug() *Client { @@ -208,7 +208,7 @@ 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.File, c.Job, c.Session, c.Tag, c.Task, c.Tome, c.User, + c.Beacon, c.File, c.Quest, c.Tag, c.Task, c.Tome, c.User, } { n.Use(hooks...) } @@ -218,7 +218,7 @@ 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.File, c.Job, c.Session, c.Tag, c.Task, c.Tome, c.User, + c.Beacon, c.File, c.Quest, c.Tag, c.Task, c.Tome, c.User, } { n.Intercept(interceptors...) } @@ -227,12 +227,12 @@ func (c *Client) Intercept(interceptors ...Interceptor) { // Mutate implements the ent.Mutator interface. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { + case *BeaconMutation: + return c.Beacon.mutate(ctx, m) case *FileMutation: return c.File.mutate(ctx, m) - case *JobMutation: - return c.Job.mutate(ctx, m) - case *SessionMutation: - return c.Session.mutate(ctx, m) + case *QuestMutation: + return c.Quest.mutate(ctx, m) case *TagMutation: return c.Tag.mutate(ctx, m) case *TaskMutation: @@ -246,6 +246,156 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { } } +// BeaconClient is a client for the Beacon schema. +type BeaconClient struct { + config +} + +// NewBeaconClient returns a client for the Beacon from the given config. +func NewBeaconClient(c config) *BeaconClient { + return &BeaconClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `beacon.Hooks(f(g(h())))`. +func (c *BeaconClient) Use(hooks ...Hook) { + c.hooks.Beacon = append(c.hooks.Beacon, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `beacon.Intercept(f(g(h())))`. +func (c *BeaconClient) Intercept(interceptors ...Interceptor) { + c.inters.Beacon = append(c.inters.Beacon, interceptors...) +} + +// Create returns a builder for creating a Beacon entity. +func (c *BeaconClient) Create() *BeaconCreate { + mutation := newBeaconMutation(c.config, OpCreate) + return &BeaconCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Beacon entities. +func (c *BeaconClient) CreateBulk(builders ...*BeaconCreate) *BeaconCreateBulk { + return &BeaconCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Beacon. +func (c *BeaconClient) Update() *BeaconUpdate { + mutation := newBeaconMutation(c.config, OpUpdate) + return &BeaconUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BeaconClient) UpdateOne(b *Beacon) *BeaconUpdateOne { + mutation := newBeaconMutation(c.config, OpUpdateOne, withBeacon(b)) + return &BeaconUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BeaconClient) UpdateOneID(id int) *BeaconUpdateOne { + mutation := newBeaconMutation(c.config, OpUpdateOne, withBeaconID(id)) + return &BeaconUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Beacon. +func (c *BeaconClient) Delete() *BeaconDelete { + mutation := newBeaconMutation(c.config, OpDelete) + return &BeaconDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BeaconClient) DeleteOne(b *Beacon) *BeaconDeleteOne { + return c.DeleteOneID(b.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *BeaconClient) DeleteOneID(id int) *BeaconDeleteOne { + builder := c.Delete().Where(beacon.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &BeaconDeleteOne{builder} +} + +// Query returns a query builder for Beacon. +func (c *BeaconClient) Query() *BeaconQuery { + return &BeaconQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeBeacon}, + inters: c.Interceptors(), + } +} + +// Get returns a Beacon entity by its id. +func (c *BeaconClient) Get(ctx context.Context, id int) (*Beacon, error) { + return c.Query().Where(beacon.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BeaconClient) GetX(ctx context.Context, id int) *Beacon { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryTags queries the tags edge of a Beacon. +func (c *BeaconClient) QueryTags(b *Beacon) *TagQuery { + query := (&TagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := b.ID + step := sqlgraph.NewStep( + sqlgraph.From(beacon.Table, beacon.FieldID, id), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, beacon.TagsTable, beacon.TagsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(b.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTasks queries the tasks edge of a Beacon. +func (c *BeaconClient) QueryTasks(b *Beacon) *TaskQuery { + query := (&TaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := b.ID + step := sqlgraph.NewStep( + sqlgraph.From(beacon.Table, beacon.FieldID, id), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, beacon.TasksTable, beacon.TasksColumn), + ) + fromV = sqlgraph.Neighbors(b.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *BeaconClient) Hooks() []Hook { + return c.hooks.Beacon +} + +// Interceptors returns the client interceptors. +func (c *BeaconClient) Interceptors() []Interceptor { + return c.inters.Beacon +} + +func (c *BeaconClient) mutate(ctx context.Context, m *BeaconMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&BeaconCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&BeaconUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&BeaconUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&BeaconDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Beacon mutation op: %q", m.Op()) + } +} + // FileClient is a client for the File schema. type FileClient struct { config @@ -365,92 +515,92 @@ func (c *FileClient) mutate(ctx context.Context, m *FileMutation) (Value, error) } } -// JobClient is a client for the Job schema. -type JobClient struct { +// QuestClient is a client for the Quest schema. +type QuestClient struct { config } -// NewJobClient returns a client for the Job from the given config. -func NewJobClient(c config) *JobClient { - return &JobClient{config: c} +// NewQuestClient returns a client for the Quest from the given config. +func NewQuestClient(c config) *QuestClient { + return &QuestClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `job.Hooks(f(g(h())))`. -func (c *JobClient) Use(hooks ...Hook) { - c.hooks.Job = append(c.hooks.Job, hooks...) +// A call to `Use(f, g, h)` equals to `quest.Hooks(f(g(h())))`. +func (c *QuestClient) Use(hooks ...Hook) { + c.hooks.Quest = append(c.hooks.Quest, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `job.Intercept(f(g(h())))`. -func (c *JobClient) Intercept(interceptors ...Interceptor) { - c.inters.Job = append(c.inters.Job, interceptors...) +// A call to `Intercept(f, g, h)` equals to `quest.Intercept(f(g(h())))`. +func (c *QuestClient) Intercept(interceptors ...Interceptor) { + c.inters.Quest = append(c.inters.Quest, interceptors...) } -// Create returns a builder for creating a Job entity. -func (c *JobClient) Create() *JobCreate { - mutation := newJobMutation(c.config, OpCreate) - return &JobCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Create returns a builder for creating a Quest entity. +func (c *QuestClient) Create() *QuestCreate { + mutation := newQuestMutation(c.config, OpCreate) + return &QuestCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// CreateBulk returns a builder for creating a bulk of Job entities. -func (c *JobClient) CreateBulk(builders ...*JobCreate) *JobCreateBulk { - return &JobCreateBulk{config: c.config, builders: builders} +// CreateBulk returns a builder for creating a bulk of Quest entities. +func (c *QuestClient) CreateBulk(builders ...*QuestCreate) *QuestCreateBulk { + return &QuestCreateBulk{config: c.config, builders: builders} } -// Update returns an update builder for Job. -func (c *JobClient) Update() *JobUpdate { - mutation := newJobMutation(c.config, OpUpdate) - return &JobUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Update returns an update builder for Quest. +func (c *QuestClient) Update() *QuestUpdate { + mutation := newQuestMutation(c.config, OpUpdate) + return &QuestUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. -func (c *JobClient) UpdateOne(j *Job) *JobUpdateOne { - mutation := newJobMutation(c.config, OpUpdateOne, withJob(j)) - return &JobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *QuestClient) UpdateOne(q *Quest) *QuestUpdateOne { + mutation := newQuestMutation(c.config, OpUpdateOne, withQuest(q)) + return &QuestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. -func (c *JobClient) UpdateOneID(id int) *JobUpdateOne { - mutation := newJobMutation(c.config, OpUpdateOne, withJobID(id)) - return &JobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *QuestClient) UpdateOneID(id int) *QuestUpdateOne { + mutation := newQuestMutation(c.config, OpUpdateOne, withQuestID(id)) + return &QuestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// Delete returns a delete builder for Job. -func (c *JobClient) Delete() *JobDelete { - mutation := newJobMutation(c.config, OpDelete) - return &JobDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Delete returns a delete builder for Quest. +func (c *QuestClient) Delete() *QuestDelete { + mutation := newQuestMutation(c.config, OpDelete) + return &QuestDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. -func (c *JobClient) DeleteOne(j *Job) *JobDeleteOne { - return c.DeleteOneID(j.ID) +func (c *QuestClient) DeleteOne(q *Quest) *QuestDeleteOne { + return c.DeleteOneID(q.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *JobClient) DeleteOneID(id int) *JobDeleteOne { - builder := c.Delete().Where(job.ID(id)) +func (c *QuestClient) DeleteOneID(id int) *QuestDeleteOne { + builder := c.Delete().Where(quest.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne - return &JobDeleteOne{builder} + return &QuestDeleteOne{builder} } -// Query returns a query builder for Job. -func (c *JobClient) Query() *JobQuery { - return &JobQuery{ +// Query returns a query builder for Quest. +func (c *QuestClient) Query() *QuestQuery { + return &QuestQuery{ config: c.config, - ctx: &QueryContext{Type: TypeJob}, + ctx: &QueryContext{Type: TypeQuest}, inters: c.Interceptors(), } } -// Get returns a Job entity by its id. -func (c *JobClient) Get(ctx context.Context, id int) (*Job, error) { - return c.Query().Where(job.ID(id)).Only(ctx) +// Get returns a Quest entity by its id. +func (c *QuestClient) Get(ctx context.Context, id int) (*Quest, error) { + return c.Query().Where(quest.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *JobClient) GetX(ctx context.Context, id int) *Job { +func (c *QuestClient) GetX(ctx context.Context, id int) *Quest { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -458,242 +608,92 @@ func (c *JobClient) GetX(ctx context.Context, id int) *Job { return obj } -// QueryTome queries the tome edge of a Job. -func (c *JobClient) QueryTome(j *Job) *TomeQuery { +// QueryTome queries the tome edge of a Quest. +func (c *QuestClient) QueryTome(q *Quest) *TomeQuery { query := (&TomeClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := j.ID + id := q.ID step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, id), + sqlgraph.From(quest.Table, quest.FieldID, id), sqlgraph.To(tome.Table, tome.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, job.TomeTable, job.TomeColumn), + sqlgraph.Edge(sqlgraph.M2O, false, quest.TomeTable, quest.TomeColumn), ) - fromV = sqlgraph.Neighbors(j.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(q.driver.Dialect(), step) return fromV, nil } return query } -// QueryBundle queries the bundle edge of a Job. -func (c *JobClient) QueryBundle(j *Job) *FileQuery { +// QueryBundle queries the bundle edge of a Quest. +func (c *QuestClient) QueryBundle(q *Quest) *FileQuery { query := (&FileClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := j.ID + id := q.ID step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, id), + sqlgraph.From(quest.Table, quest.FieldID, id), sqlgraph.To(file.Table, file.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, job.BundleTable, job.BundleColumn), + sqlgraph.Edge(sqlgraph.M2O, false, quest.BundleTable, quest.BundleColumn), ) - fromV = sqlgraph.Neighbors(j.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(q.driver.Dialect(), step) return fromV, nil } return query } -// QueryTasks queries the tasks edge of a Job. -func (c *JobClient) QueryTasks(j *Job) *TaskQuery { +// QueryTasks queries the tasks edge of a Quest. +func (c *QuestClient) QueryTasks(q *Quest) *TaskQuery { query := (&TaskClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := j.ID + id := q.ID step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, id), + sqlgraph.From(quest.Table, quest.FieldID, id), sqlgraph.To(task.Table, task.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, job.TasksTable, job.TasksColumn), + sqlgraph.Edge(sqlgraph.O2M, false, quest.TasksTable, quest.TasksColumn), ) - fromV = sqlgraph.Neighbors(j.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(q.driver.Dialect(), step) return fromV, nil } return query } -// QueryCreator queries the creator edge of a Job. -func (c *JobClient) QueryCreator(j *Job) *UserQuery { +// QueryCreator queries the creator edge of a Quest. +func (c *QuestClient) QueryCreator(q *Quest) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := j.ID + id := q.ID step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, id), + sqlgraph.From(quest.Table, quest.FieldID, id), sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, job.CreatorTable, job.CreatorColumn), - ) - fromV = sqlgraph.Neighbors(j.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *JobClient) Hooks() []Hook { - return c.hooks.Job -} - -// Interceptors returns the client interceptors. -func (c *JobClient) Interceptors() []Interceptor { - return c.inters.Job -} - -func (c *JobClient) mutate(ctx context.Context, m *JobMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&JobCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&JobUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&JobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&JobDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Job mutation op: %q", m.Op()) - } -} - -// SessionClient is a client for the Session schema. -type SessionClient struct { - config -} - -// NewSessionClient returns a client for the Session from the given config. -func NewSessionClient(c config) *SessionClient { - return &SessionClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `session.Hooks(f(g(h())))`. -func (c *SessionClient) Use(hooks ...Hook) { - c.hooks.Session = append(c.hooks.Session, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `session.Intercept(f(g(h())))`. -func (c *SessionClient) Intercept(interceptors ...Interceptor) { - c.inters.Session = append(c.inters.Session, interceptors...) -} - -// Create returns a builder for creating a Session entity. -func (c *SessionClient) Create() *SessionCreate { - mutation := newSessionMutation(c.config, OpCreate) - return &SessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Session entities. -func (c *SessionClient) CreateBulk(builders ...*SessionCreate) *SessionCreateBulk { - return &SessionCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Session. -func (c *SessionClient) Update() *SessionUpdate { - mutation := newSessionMutation(c.config, OpUpdate) - return &SessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *SessionClient) UpdateOne(s *Session) *SessionUpdateOne { - mutation := newSessionMutation(c.config, OpUpdateOne, withSession(s)) - return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *SessionClient) UpdateOneID(id int) *SessionUpdateOne { - mutation := newSessionMutation(c.config, OpUpdateOne, withSessionID(id)) - return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Session. -func (c *SessionClient) Delete() *SessionDelete { - mutation := newSessionMutation(c.config, OpDelete) - return &SessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *SessionClient) DeleteOne(s *Session) *SessionDeleteOne { - return c.DeleteOneID(s.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *SessionClient) DeleteOneID(id int) *SessionDeleteOne { - builder := c.Delete().Where(session.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &SessionDeleteOne{builder} -} - -// Query returns a query builder for Session. -func (c *SessionClient) Query() *SessionQuery { - return &SessionQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeSession}, - inters: c.Interceptors(), - } -} - -// Get returns a Session entity by its id. -func (c *SessionClient) Get(ctx context.Context, id int) (*Session, error) { - return c.Query().Where(session.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *SessionClient) GetX(ctx context.Context, id int) *Session { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryTags queries the tags edge of a Session. -func (c *SessionClient) QueryTags(s *Session) *TagQuery { - query := (&TagClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(session.Table, session.FieldID, id), - sqlgraph.To(tag.Table, tag.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, session.TagsTable, session.TagsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryTasks queries the tasks edge of a Session. -func (c *SessionClient) QueryTasks(s *Session) *TaskQuery { - query := (&TaskClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(session.Table, session.FieldID, id), - sqlgraph.To(task.Table, task.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, session.TasksTable, session.TasksColumn), + sqlgraph.Edge(sqlgraph.M2O, false, quest.CreatorTable, quest.CreatorColumn), ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(q.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. -func (c *SessionClient) Hooks() []Hook { - return c.hooks.Session +func (c *QuestClient) Hooks() []Hook { + return c.hooks.Quest } // Interceptors returns the client interceptors. -func (c *SessionClient) Interceptors() []Interceptor { - return c.inters.Session +func (c *QuestClient) Interceptors() []Interceptor { + return c.inters.Quest } -func (c *SessionClient) mutate(ctx context.Context, m *SessionMutation) (Value, error) { +func (c *QuestClient) mutate(ctx context.Context, m *QuestMutation) (Value, error) { switch m.Op() { case OpCreate: - return (&SessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&QuestCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: - return (&SessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&QuestUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: - return (&SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&QuestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: - return (&SessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + return (&QuestDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: - return nil, fmt.Errorf("ent: unknown Session mutation op: %q", m.Op()) + return nil, fmt.Errorf("ent: unknown Quest mutation op: %q", m.Op()) } } @@ -790,15 +790,15 @@ func (c *TagClient) GetX(ctx context.Context, id int) *Tag { return obj } -// QuerySessions queries the sessions edge of a Tag. -func (c *TagClient) QuerySessions(t *Tag) *SessionQuery { - query := (&SessionClient{config: c.config}).Query() +// QueryBeacons queries the beacons edge of a Tag. +func (c *TagClient) QueryBeacons(t *Tag) *BeaconQuery { + query := (&BeaconClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := t.ID step := sqlgraph.NewStep( sqlgraph.From(tag.Table, tag.FieldID, id), - sqlgraph.To(session.Table, session.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, tag.SessionsTable, tag.SessionsPrimaryKey...), + sqlgraph.To(beacon.Table, beacon.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.BeaconsTable, tag.BeaconsPrimaryKey...), ) fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) return fromV, nil @@ -924,15 +924,15 @@ func (c *TaskClient) GetX(ctx context.Context, id int) *Task { return obj } -// QueryJob queries the job edge of a Task. -func (c *TaskClient) QueryJob(t *Task) *JobQuery { - query := (&JobClient{config: c.config}).Query() +// QueryQuest queries the quest edge of a Task. +func (c *TaskClient) QueryQuest(t *Task) *QuestQuery { + query := (&QuestClient{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(job.Table, job.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, task.JobTable, task.JobColumn), + sqlgraph.To(quest.Table, quest.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, task.QuestTable, task.QuestColumn), ) fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) return fromV, nil @@ -940,15 +940,15 @@ func (c *TaskClient) QueryJob(t *Task) *JobQuery { return query } -// QuerySession queries the session edge of a Task. -func (c *TaskClient) QuerySession(t *Task) *SessionQuery { - query := (&SessionClient{config: c.config}).Query() +// QueryBeacon queries the beacon edge of a Task. +func (c *TaskClient) QueryBeacon(t *Task) *BeaconQuery { + query := (&BeaconClient{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(session.Table, session.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, task.SessionTable, task.SessionColumn), + sqlgraph.To(beacon.Table, beacon.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, task.BeaconTable, task.BeaconColumn), ) fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) return fromV, nil @@ -1237,9 +1237,9 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - File, Job, Session, Tag, Task, Tome, User []ent.Hook + Beacon, File, Quest, Tag, Task, Tome, User []ent.Hook } inters struct { - File, Job, Session, Tag, Task, Tome, User []ent.Interceptor + Beacon, File, Quest, Tag, Task, Tome, User []ent.Interceptor } ) diff --git a/tavern/ent/ent.go b/tavern/ent/ent.go index b1c649de4..47d857f4e 100644 --- a/tavern/ent/ent.go +++ b/tavern/ent/ent.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" @@ -71,13 +71,13 @@ type OrderFunc func(*sql.Selector) // columnChecker returns a function indicates if the column exists in the given column. func columnChecker(table string) func(string) error { checks := map[string]func(string) bool{ - file.Table: file.ValidColumn, - job.Table: job.ValidColumn, - session.Table: session.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, + quest.Table: quest.ValidColumn, + tag.Table: tag.ValidColumn, + task.Table: task.ValidColumn, + tome.Table: tome.ValidColumn, + user.Table: user.ValidColumn, } check, ok := checks[table] if !ok { diff --git a/tavern/ent/gql_collection.go b/tavern/ent/gql_collection.go index 5baa878eb..12156454a 100644 --- a/tavern/ent/gql_collection.go +++ b/tavern/ent/gql_collection.go @@ -10,30 +10,58 @@ import ( ) // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (f *FileQuery) CollectFields(ctx context.Context, satisfies ...string) (*FileQuery, error) { +func (b *BeaconQuery) CollectFields(ctx context.Context, satisfies ...string) (*BeaconQuery, error) { fc := graphql.GetFieldContext(ctx) if fc == nil { - return f, nil + return b, nil } - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := b.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } - return f, nil + return b, nil } -func (f *FileQuery) collectField(ctx context.Context, op *graphql.OperationContext, field graphql.CollectedField, path []string, satisfies ...string) error { +func (b *BeaconQuery) collectField(ctx context.Context, op *graphql.OperationContext, field graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) + for _, field := range graphql.CollectFields(op, field.Selections, satisfies) { + switch field.Name { + case "tags": + var ( + alias = field.Alias + path = append(path, alias) + query = (&TagClient{config: b.config}).Query() + ) + if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { + return err + } + b.WithNamedTags(alias, func(wq *TagQuery) { + *wq = *query + }) + case "tasks": + var ( + alias = field.Alias + path = append(path, alias) + query = (&TaskClient{config: b.config}).Query() + ) + if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { + return err + } + b.WithNamedTasks(alias, func(wq *TaskQuery) { + *wq = *query + }) + } + } return nil } -type filePaginateArgs struct { +type beaconPaginateArgs struct { first, last *int after, before *Cursor - opts []FilePaginateOption + opts []BeaconPaginateOption } -func newFilePaginateArgs(rv map[string]interface{}) *filePaginateArgs { - args := &filePaginateArgs{} +func newBeaconPaginateArgs(rv map[string]interface{}) *beaconPaginateArgs { + args := &beaconPaginateArgs{} if rv == nil { return args } @@ -54,7 +82,7 @@ func newFilePaginateArgs(rv map[string]interface{}) *filePaginateArgs { case map[string]interface{}: var ( err1, err2 error - order = &FileOrder{Field: &FileOrderField{}} + order = &BeaconOrder{Field: &BeaconOrderField{}} ) if d, ok := v[directionField]; ok { err1 = order.Direction.UnmarshalGQL(d) @@ -63,91 +91,45 @@ func newFilePaginateArgs(rv map[string]interface{}) *filePaginateArgs { err2 = order.Field.UnmarshalGQL(f) } if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithFileOrder(order)) + args.opts = append(args.opts, WithBeaconOrder(order)) } - case *FileOrder: + case *BeaconOrder: if v != nil { - args.opts = append(args.opts, WithFileOrder(v)) + args.opts = append(args.opts, WithBeaconOrder(v)) } } } - if v, ok := rv[whereField].(*FileWhereInput); ok { - args.opts = append(args.opts, WithFileFilter(v.Filter)) + if v, ok := rv[whereField].(*BeaconWhereInput); ok { + args.opts = append(args.opts, WithBeaconFilter(v.Filter)) } return args } // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (j *JobQuery) CollectFields(ctx context.Context, satisfies ...string) (*JobQuery, error) { +func (f *FileQuery) CollectFields(ctx context.Context, satisfies ...string) (*FileQuery, error) { fc := graphql.GetFieldContext(ctx) if fc == nil { - return j, nil + return f, nil } - if err := j.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := f.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } - return j, nil + return f, nil } -func (j *JobQuery) collectField(ctx context.Context, op *graphql.OperationContext, field graphql.CollectedField, path []string, satisfies ...string) error { +func (f *FileQuery) collectField(ctx context.Context, op *graphql.OperationContext, field graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) - for _, field := range graphql.CollectFields(op, field.Selections, satisfies) { - switch field.Name { - case "tome": - var ( - alias = field.Alias - path = append(path, alias) - query = (&TomeClient{config: j.config}).Query() - ) - if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { - return err - } - j.withTome = query - case "bundle": - var ( - alias = field.Alias - path = append(path, alias) - query = (&FileClient{config: j.config}).Query() - ) - if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { - return err - } - j.withBundle = query - case "tasks": - var ( - alias = field.Alias - path = append(path, alias) - query = (&TaskClient{config: j.config}).Query() - ) - if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { - return err - } - j.WithNamedTasks(alias, func(wq *TaskQuery) { - *wq = *query - }) - case "creator": - var ( - alias = field.Alias - path = append(path, alias) - query = (&UserClient{config: j.config}).Query() - ) - if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { - return err - } - j.withCreator = query - } - } return nil } -type jobPaginateArgs struct { +type filePaginateArgs struct { first, last *int after, before *Cursor - opts []JobPaginateOption + opts []FilePaginateOption } -func newJobPaginateArgs(rv map[string]interface{}) *jobPaginateArgs { - args := &jobPaginateArgs{} +func newFilePaginateArgs(rv map[string]interface{}) *filePaginateArgs { + args := &filePaginateArgs{} if rv == nil { return args } @@ -168,7 +150,7 @@ func newJobPaginateArgs(rv map[string]interface{}) *jobPaginateArgs { case map[string]interface{}: var ( err1, err2 error - order = &JobOrder{Field: &JobOrderField{}} + order = &FileOrder{Field: &FileOrderField{}} ) if d, ok := v[directionField]; ok { err1 = order.Direction.UnmarshalGQL(d) @@ -177,73 +159,91 @@ func newJobPaginateArgs(rv map[string]interface{}) *jobPaginateArgs { err2 = order.Field.UnmarshalGQL(f) } if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithJobOrder(order)) + args.opts = append(args.opts, WithFileOrder(order)) } - case *JobOrder: + case *FileOrder: if v != nil { - args.opts = append(args.opts, WithJobOrder(v)) + args.opts = append(args.opts, WithFileOrder(v)) } } } - if v, ok := rv[whereField].(*JobWhereInput); ok { - args.opts = append(args.opts, WithJobFilter(v.Filter)) + if v, ok := rv[whereField].(*FileWhereInput); ok { + args.opts = append(args.opts, WithFileFilter(v.Filter)) } return args } // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (s *SessionQuery) CollectFields(ctx context.Context, satisfies ...string) (*SessionQuery, error) { +func (q *QuestQuery) CollectFields(ctx context.Context, satisfies ...string) (*QuestQuery, error) { fc := graphql.GetFieldContext(ctx) if fc == nil { - return s, nil + return q, nil } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := q.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } - return s, nil + return q, nil } -func (s *SessionQuery) collectField(ctx context.Context, op *graphql.OperationContext, field graphql.CollectedField, path []string, satisfies ...string) error { +func (q *QuestQuery) collectField(ctx context.Context, op *graphql.OperationContext, field graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) for _, field := range graphql.CollectFields(op, field.Selections, satisfies) { switch field.Name { - case "tags": + case "tome": var ( alias = field.Alias path = append(path, alias) - query = (&TagClient{config: s.config}).Query() + query = (&TomeClient{config: q.config}).Query() ) if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { return err } - s.WithNamedTags(alias, func(wq *TagQuery) { - *wq = *query - }) + q.withTome = query + case "bundle": + var ( + alias = field.Alias + path = append(path, alias) + query = (&FileClient{config: q.config}).Query() + ) + if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { + return err + } + q.withBundle = query case "tasks": var ( alias = field.Alias path = append(path, alias) - query = (&TaskClient{config: s.config}).Query() + query = (&TaskClient{config: q.config}).Query() ) if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { return err } - s.WithNamedTasks(alias, func(wq *TaskQuery) { + q.WithNamedTasks(alias, func(wq *TaskQuery) { *wq = *query }) + case "creator": + var ( + alias = field.Alias + path = append(path, alias) + query = (&UserClient{config: q.config}).Query() + ) + if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { + return err + } + q.withCreator = query } } return nil } -type sessionPaginateArgs struct { +type questPaginateArgs struct { first, last *int after, before *Cursor - opts []SessionPaginateOption + opts []QuestPaginateOption } -func newSessionPaginateArgs(rv map[string]interface{}) *sessionPaginateArgs { - args := &sessionPaginateArgs{} +func newQuestPaginateArgs(rv map[string]interface{}) *questPaginateArgs { + args := &questPaginateArgs{} if rv == nil { return args } @@ -264,7 +264,7 @@ func newSessionPaginateArgs(rv map[string]interface{}) *sessionPaginateArgs { case map[string]interface{}: var ( err1, err2 error - order = &SessionOrder{Field: &SessionOrderField{}} + order = &QuestOrder{Field: &QuestOrderField{}} ) if d, ok := v[directionField]; ok { err1 = order.Direction.UnmarshalGQL(d) @@ -273,16 +273,16 @@ func newSessionPaginateArgs(rv map[string]interface{}) *sessionPaginateArgs { err2 = order.Field.UnmarshalGQL(f) } if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithSessionOrder(order)) + args.opts = append(args.opts, WithQuestOrder(order)) } - case *SessionOrder: + case *QuestOrder: if v != nil { - args.opts = append(args.opts, WithSessionOrder(v)) + args.opts = append(args.opts, WithQuestOrder(v)) } } } - if v, ok := rv[whereField].(*SessionWhereInput); ok { - args.opts = append(args.opts, WithSessionFilter(v.Filter)) + if v, ok := rv[whereField].(*QuestWhereInput); ok { + args.opts = append(args.opts, WithQuestFilter(v.Filter)) } return args } @@ -303,16 +303,16 @@ func (t *TagQuery) collectField(ctx context.Context, op *graphql.OperationContex path = append([]string(nil), path...) for _, field := range graphql.CollectFields(op, field.Selections, satisfies) { switch field.Name { - case "sessions": + case "beacons": var ( alias = field.Alias path = append(path, alias) - query = (&SessionClient{config: t.config}).Query() + query = (&BeaconClient{config: t.config}).Query() ) if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { return err } - t.WithNamedSessions(alias, func(wq *SessionQuery) { + t.WithNamedBeacons(alias, func(wq *BeaconQuery) { *wq = *query }) } @@ -387,26 +387,26 @@ func (t *TaskQuery) collectField(ctx context.Context, op *graphql.OperationConte path = append([]string(nil), path...) for _, field := range graphql.CollectFields(op, field.Selections, satisfies) { switch field.Name { - case "job": + case "quest": var ( alias = field.Alias path = append(path, alias) - query = (&JobClient{config: t.config}).Query() + query = (&QuestClient{config: t.config}).Query() ) if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { return err } - t.withJob = query - case "session": + t.withQuest = query + case "beacon": var ( alias = field.Alias path = append(path, alias) - query = (&SessionClient{config: t.config}).Query() + query = (&BeaconClient{config: t.config}).Query() ) if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { return err } - t.withSession = query + t.withBeacon = query } } return nil diff --git a/tavern/ent/gql_edge.go b/tavern/ent/gql_edge.go index 9fd699274..671c48262 100644 --- a/tavern/ent/gql_edge.go +++ b/tavern/ent/gql_edge.go @@ -8,90 +8,90 @@ import ( "github.com/99designs/gqlgen/graphql" ) -func (j *Job) Tome(ctx context.Context) (*Tome, error) { - result, err := j.Edges.TomeOrErr() +func (b *Beacon) Tags(ctx context.Context) (result []*Tag, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = b.NamedTags(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = b.Edges.TagsOrErr() + } if IsNotLoaded(err) { - result, err = j.QueryTome().Only(ctx) + result, err = b.QueryTags().All(ctx) } return result, err } -func (j *Job) Bundle(ctx context.Context) (*File, error) { - result, err := j.Edges.BundleOrErr() +func (b *Beacon) Tasks(ctx context.Context) (result []*Task, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = b.NamedTasks(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = b.Edges.TasksOrErr() + } if IsNotLoaded(err) { - result, err = j.QueryBundle().Only(ctx) + result, err = b.QueryTasks().All(ctx) } - return result, MaskNotFound(err) + return result, err } -func (j *Job) Tasks(ctx context.Context) (result []*Task, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = j.NamedTasks(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = j.Edges.TasksOrErr() - } +func (q *Quest) Tome(ctx context.Context) (*Tome, error) { + result, err := q.Edges.TomeOrErr() if IsNotLoaded(err) { - result, err = j.QueryTasks().All(ctx) + result, err = q.QueryTome().Only(ctx) } return result, err } -func (j *Job) Creator(ctx context.Context) (*User, error) { - result, err := j.Edges.CreatorOrErr() +func (q *Quest) Bundle(ctx context.Context) (*File, error) { + result, err := q.Edges.BundleOrErr() if IsNotLoaded(err) { - result, err = j.QueryCreator().Only(ctx) + result, err = q.QueryBundle().Only(ctx) } return result, MaskNotFound(err) } -func (s *Session) Tags(ctx context.Context) (result []*Tag, err error) { +func (q *Quest) Tasks(ctx context.Context) (result []*Task, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedTags(graphql.GetFieldContext(ctx).Field.Alias) + result, err = q.NamedTasks(graphql.GetFieldContext(ctx).Field.Alias) } else { - result, err = s.Edges.TagsOrErr() + result, err = q.Edges.TasksOrErr() } if IsNotLoaded(err) { - result, err = s.QueryTags().All(ctx) + result, err = q.QueryTasks().All(ctx) } return result, err } -func (s *Session) Tasks(ctx context.Context) (result []*Task, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedTasks(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = s.Edges.TasksOrErr() - } +func (q *Quest) Creator(ctx context.Context) (*User, error) { + result, err := q.Edges.CreatorOrErr() if IsNotLoaded(err) { - result, err = s.QueryTasks().All(ctx) + result, err = q.QueryCreator().Only(ctx) } - return result, err + return result, MaskNotFound(err) } -func (t *Tag) Sessions(ctx context.Context) (result []*Session, err error) { +func (t *Tag) Beacons(ctx context.Context) (result []*Beacon, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = t.NamedSessions(graphql.GetFieldContext(ctx).Field.Alias) + result, err = t.NamedBeacons(graphql.GetFieldContext(ctx).Field.Alias) } else { - result, err = t.Edges.SessionsOrErr() + result, err = t.Edges.BeaconsOrErr() } if IsNotLoaded(err) { - result, err = t.QuerySessions().All(ctx) + result, err = t.QueryBeacons().All(ctx) } return result, err } -func (t *Task) Job(ctx context.Context) (*Job, error) { - result, err := t.Edges.JobOrErr() +func (t *Task) Quest(ctx context.Context) (*Quest, error) { + result, err := t.Edges.QuestOrErr() if IsNotLoaded(err) { - result, err = t.QueryJob().Only(ctx) + result, err = t.QueryQuest().Only(ctx) } return result, err } -func (t *Task) Session(ctx context.Context) (*Session, error) { - result, err := t.Edges.SessionOrErr() +func (t *Task) Beacon(ctx context.Context) (*Beacon, error) { + result, err := t.Edges.BeaconOrErr() if IsNotLoaded(err) { - result, err = t.QuerySession().Only(ctx) + result, err = t.QueryBeacon().Only(ctx) } return result, err } diff --git a/tavern/ent/gql_mutation_input.go b/tavern/ent/gql_mutation_input.go index 6836ce567..7258bc59c 100644 --- a/tavern/ent/gql_mutation_input.go +++ b/tavern/ent/gql_mutation_input.go @@ -6,30 +6,8 @@ import ( "github.com/kcarretto/realm/tavern/ent/tag" ) -// CreateJobInput represents a mutation input for creating jobs. -type CreateJobInput struct { - Name string - Parameters *string - TomeID int -} - -// Mutate applies the CreateJobInput on the JobMutation builder. -func (i *CreateJobInput) Mutate(m *JobMutation) { - m.SetName(i.Name) - if v := i.Parameters; v != nil { - m.SetParameters(*v) - } - m.SetTomeID(i.TomeID) -} - -// SetInput applies the change-set in the CreateJobInput on the JobCreate builder. -func (c *JobCreate) SetInput(i CreateJobInput) *JobCreate { - i.Mutate(c.Mutation()) - return c -} - -// UpdateSessionInput represents a mutation input for updating sessions. -type UpdateSessionInput struct { +// UpdateBeaconInput represents a mutation input for updating beacons. +type UpdateBeaconInput struct { Name *string ClearHostname bool Hostname *string @@ -38,8 +16,8 @@ type UpdateSessionInput struct { RemoveTagIDs []int } -// Mutate applies the UpdateSessionInput on the SessionMutation builder. -func (i *UpdateSessionInput) Mutate(m *SessionMutation) { +// Mutate applies the UpdateBeaconInput on the BeaconMutation builder. +func (i *UpdateBeaconInput) Mutate(m *BeaconMutation) { if v := i.Name; v != nil { m.SetName(*v) } @@ -60,31 +38,53 @@ func (i *UpdateSessionInput) Mutate(m *SessionMutation) { } } -// SetInput applies the change-set in the UpdateSessionInput on the SessionUpdate builder. -func (c *SessionUpdate) SetInput(i UpdateSessionInput) *SessionUpdate { +// SetInput applies the change-set in the UpdateBeaconInput on the BeaconUpdate builder. +func (c *BeaconUpdate) SetInput(i UpdateBeaconInput) *BeaconUpdate { i.Mutate(c.Mutation()) return c } -// SetInput applies the change-set in the UpdateSessionInput on the SessionUpdateOne builder. -func (c *SessionUpdateOne) SetInput(i UpdateSessionInput) *SessionUpdateOne { +// SetInput applies the change-set in the UpdateBeaconInput on the BeaconUpdateOne builder. +func (c *BeaconUpdateOne) SetInput(i UpdateBeaconInput) *BeaconUpdateOne { + i.Mutate(c.Mutation()) + return c +} + +// CreateQuestInput represents a mutation input for creating quests. +type CreateQuestInput struct { + Name string + Parameters *string + TomeID int +} + +// Mutate applies the CreateQuestInput on the QuestMutation builder. +func (i *CreateQuestInput) Mutate(m *QuestMutation) { + m.SetName(i.Name) + if v := i.Parameters; v != nil { + m.SetParameters(*v) + } + m.SetTomeID(i.TomeID) +} + +// SetInput applies the change-set in the CreateQuestInput on the QuestCreate builder. +func (c *QuestCreate) SetInput(i CreateQuestInput) *QuestCreate { i.Mutate(c.Mutation()) return c } // CreateTagInput represents a mutation input for creating tags. type CreateTagInput struct { - Name string - Kind tag.Kind - SessionIDs []int + Name string + Kind tag.Kind + BeaconIDs []int } // Mutate applies the CreateTagInput on the TagMutation builder. func (i *CreateTagInput) Mutate(m *TagMutation) { m.SetName(i.Name) m.SetKind(i.Kind) - if v := i.SessionIDs; len(v) > 0 { - m.AddSessionIDs(v...) + if v := i.BeaconIDs; len(v) > 0 { + m.AddBeaconIDs(v...) } } @@ -96,11 +96,11 @@ func (c *TagCreate) SetInput(i CreateTagInput) *TagCreate { // UpdateTagInput represents a mutation input for updating tags. type UpdateTagInput struct { - Name *string - Kind *tag.Kind - ClearSessions bool - AddSessionIDs []int - RemoveSessionIDs []int + Name *string + Kind *tag.Kind + ClearBeacons bool + AddBeaconIDs []int + RemoveBeaconIDs []int } // Mutate applies the UpdateTagInput on the TagMutation builder. @@ -111,14 +111,14 @@ func (i *UpdateTagInput) Mutate(m *TagMutation) { if v := i.Kind; v != nil { m.SetKind(*v) } - if i.ClearSessions { - m.ClearSessions() + if i.ClearBeacons { + m.ClearBeacons() } - if v := i.AddSessionIDs; len(v) > 0 { - m.AddSessionIDs(v...) + if v := i.AddBeaconIDs; len(v) > 0 { + m.AddBeaconIDs(v...) } - if v := i.RemoveSessionIDs; len(v) > 0 { - m.RemoveSessionIDs(v...) + if v := i.RemoveBeaconIDs; len(v) > 0 { + m.RemoveBeaconIDs(v...) } } diff --git a/tavern/ent/gql_node.go b/tavern/ent/gql_node.go index 8fc4d3cfb..fe682fc6f 100644 --- a/tavern/ent/gql_node.go +++ b/tavern/ent/gql_node.go @@ -14,9 +14,9 @@ import ( "entgo.io/ent/dialect/sql/schema" "github.com/99designs/gqlgen/graphql" "github.com/hashicorp/go-multierror" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" @@ -30,13 +30,13 @@ type Noder interface { } // IsNode implements the Node interface check for GQLGen. -func (n *File) IsNode() {} +func (n *Beacon) IsNode() {} // IsNode implements the Node interface check for GQLGen. -func (n *Job) IsNode() {} +func (n *File) IsNode() {} // IsNode implements the Node interface check for GQLGen. -func (n *Session) IsNode() {} +func (n *Quest) IsNode() {} // IsNode implements the Node interface check for GQLGen. func (n *Tag) IsNode() {} @@ -108,10 +108,10 @@ func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) { switch table { - case file.Table: - query := c.File.Query(). - Where(file.ID(id)) - query, err := query.CollectFields(ctx, "File") + case beacon.Table: + query := c.Beacon.Query(). + Where(beacon.ID(id)) + query, err := query.CollectFields(ctx, "Beacon") if err != nil { return nil, err } @@ -120,10 +120,10 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) return nil, err } return n, nil - case job.Table: - query := c.Job.Query(). - Where(job.ID(id)) - query, err := query.CollectFields(ctx, "Job") + case file.Table: + query := c.File.Query(). + Where(file.ID(id)) + query, err := query.CollectFields(ctx, "File") if err != nil { return nil, err } @@ -132,10 +132,10 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) return nil, err } return n, nil - case session.Table: - query := c.Session.Query(). - Where(session.ID(id)) - query, err := query.CollectFields(ctx, "Session") + case quest.Table: + query := c.Quest.Query(). + Where(quest.ID(id)) + query, err := query.CollectFields(ctx, "Quest") if err != nil { return nil, err } @@ -265,10 +265,10 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, idmap[id] = append(idmap[id], &noders[i]) } switch table { - case file.Table: - query := c.File.Query(). - Where(file.IDIn(ids...)) - query, err := query.CollectFields(ctx, "File") + case beacon.Table: + query := c.Beacon.Query(). + Where(beacon.IDIn(ids...)) + query, err := query.CollectFields(ctx, "Beacon") if err != nil { return nil, err } @@ -281,10 +281,10 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } - case job.Table: - query := c.Job.Query(). - Where(job.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Job") + case file.Table: + query := c.File.Query(). + Where(file.IDIn(ids...)) + query, err := query.CollectFields(ctx, "File") if err != nil { return nil, err } @@ -297,10 +297,10 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } - case session.Table: - query := c.Session.Query(). - Where(session.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Session") + case quest.Table: + query := c.Quest.Query(). + Where(quest.IDIn(ids...)) + query, err := query.CollectFields(ctx, "Quest") if err != nil { return nil, err } diff --git a/tavern/ent/gql_pagination.go b/tavern/ent/gql_pagination.go index 81751e09d..6ceb10f9d 100644 --- a/tavern/ent/gql_pagination.go +++ b/tavern/ent/gql_pagination.go @@ -14,9 +14,9 @@ import ( "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/errcode" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" @@ -247,20 +247,20 @@ func paginateLimit(first, last *int) int { return limit } -// FileEdge is the edge representation of File. -type FileEdge struct { - Node *File `json:"node"` - Cursor Cursor `json:"cursor"` +// BeaconEdge is the edge representation of Beacon. +type BeaconEdge struct { + Node *Beacon `json:"node"` + Cursor Cursor `json:"cursor"` } -// FileConnection is the connection containing edges to File. -type FileConnection struct { - Edges []*FileEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` +// BeaconConnection is the connection containing edges to Beacon. +type BeaconConnection struct { + Edges []*BeaconEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` } -func (c *FileConnection) build(nodes []*File, pager *filePager, after *Cursor, first *int, before *Cursor, last *int) { +func (c *BeaconConnection) build(nodes []*Beacon, pager *beaconPager, 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) { @@ -270,21 +270,21 @@ func (c *FileConnection) build(nodes []*File, pager *filePager, after *Cursor, f c.PageInfo.HasPreviousPage = true nodes = nodes[:len(nodes)-1] } - var nodeAt func(int) *File + var nodeAt func(int) *Beacon if last != nil { n := len(nodes) - 1 - nodeAt = func(i int) *File { + nodeAt = func(i int) *Beacon { return nodes[n-i] } } else { - nodeAt = func(i int) *File { + nodeAt = func(i int) *Beacon { return nodes[i] } } - c.Edges = make([]*FileEdge, len(nodes)) + c.Edges = make([]*BeaconEdge, len(nodes)) for i := range nodes { node := nodeAt(i) - c.Edges[i] = &FileEdge{ + c.Edges[i] = &BeaconEdge{ Node: node, Cursor: pager.toCursor(node), } @@ -298,123 +298,123 @@ func (c *FileConnection) build(nodes []*File, pager *filePager, after *Cursor, f } } -// FilePaginateOption enables pagination customization. -type FilePaginateOption func(*filePager) error +// BeaconPaginateOption enables pagination customization. +type BeaconPaginateOption func(*beaconPager) error -// WithFileOrder configures pagination ordering. -func WithFileOrder(order *FileOrder) FilePaginateOption { +// WithBeaconOrder configures pagination ordering. +func WithBeaconOrder(order *BeaconOrder) BeaconPaginateOption { if order == nil { - order = DefaultFileOrder + order = DefaultBeaconOrder } o := *order - return func(pager *filePager) error { + return func(pager *beaconPager) error { if err := o.Direction.Validate(); err != nil { return err } if o.Field == nil { - o.Field = DefaultFileOrder.Field + o.Field = DefaultBeaconOrder.Field } pager.order = &o return nil } } -// WithFileFilter configures pagination filter. -func WithFileFilter(filter func(*FileQuery) (*FileQuery, error)) FilePaginateOption { - return func(pager *filePager) error { +// WithBeaconFilter configures pagination filter. +func WithBeaconFilter(filter func(*BeaconQuery) (*BeaconQuery, error)) BeaconPaginateOption { + return func(pager *beaconPager) error { if filter == nil { - return errors.New("FileQuery filter cannot be nil") + return errors.New("BeaconQuery filter cannot be nil") } pager.filter = filter return nil } } -type filePager struct { - order *FileOrder - filter func(*FileQuery) (*FileQuery, error) +type beaconPager struct { + order *BeaconOrder + filter func(*BeaconQuery) (*BeaconQuery, error) } -func newFilePager(opts []FilePaginateOption) (*filePager, error) { - pager := &filePager{} +func newBeaconPager(opts []BeaconPaginateOption) (*beaconPager, error) { + pager := &beaconPager{} for _, opt := range opts { if err := opt(pager); err != nil { return nil, err } } if pager.order == nil { - pager.order = DefaultFileOrder + pager.order = DefaultBeaconOrder } return pager, nil } -func (p *filePager) applyFilter(query *FileQuery) (*FileQuery, error) { +func (p *beaconPager) applyFilter(query *BeaconQuery) (*BeaconQuery, error) { if p.filter != nil { return p.filter(query) } return query, nil } -func (p *filePager) toCursor(f *File) Cursor { - return p.order.Field.toCursor(f) +func (p *beaconPager) toCursor(b *Beacon) Cursor { + return p.order.Field.toCursor(b) } -func (p *filePager) applyCursors(query *FileQuery, after, before *Cursor) *FileQuery { +func (p *beaconPager) applyCursors(query *BeaconQuery, after, before *Cursor) *BeaconQuery { for _, predicate := range cursorsToPredicates( p.order.Direction, after, before, - p.order.Field.field, DefaultFileOrder.Field.field, + p.order.Field.field, DefaultBeaconOrder.Field.field, ) { query = query.Where(predicate) } return query } -func (p *filePager) applyOrder(query *FileQuery, reverse bool) *FileQuery { +func (p *beaconPager) applyOrder(query *BeaconQuery, reverse bool) *BeaconQuery { direction := p.order.Direction if reverse { direction = direction.reverse() } query = query.Order(direction.orderFunc(p.order.Field.field)) - if p.order.Field != DefaultFileOrder.Field { - query = query.Order(direction.orderFunc(DefaultFileOrder.Field.field)) + if p.order.Field != DefaultBeaconOrder.Field { + query = query.Order(direction.orderFunc(DefaultBeaconOrder.Field.field)) } return query } -func (p *filePager) orderExpr(reverse bool) sql.Querier { +func (p *beaconPager) orderExpr(reverse bool) sql.Querier { direction := p.order.Direction if reverse { direction = direction.reverse() } return sql.ExprFunc(func(b *sql.Builder) { b.Ident(p.order.Field.field).Pad().WriteString(string(direction)) - if p.order.Field != DefaultFileOrder.Field { - b.Comma().Ident(DefaultFileOrder.Field.field).Pad().WriteString(string(direction)) + if p.order.Field != DefaultBeaconOrder.Field { + b.Comma().Ident(DefaultBeaconOrder.Field.field).Pad().WriteString(string(direction)) } }) } -// Paginate executes the query and returns a relay based cursor connection to File. -func (f *FileQuery) Paginate( +// Paginate executes the query and returns a relay based cursor connection to Beacon. +func (b *BeaconQuery) Paginate( ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...FilePaginateOption, -) (*FileConnection, error) { + before *Cursor, last *int, opts ...BeaconPaginateOption, +) (*BeaconConnection, error) { if err := validateFirstLast(first, last); err != nil { return nil, err } - pager, err := newFilePager(opts) + pager, err := newBeaconPager(opts) if err != nil { return nil, err } - if f, err = pager.applyFilter(f); err != nil { + if b, err = pager.applyFilter(b); err != nil { return nil, err } - conn := &FileConnection{Edges: []*FileEdge{}} + conn := &BeaconConnection{Edges: []*BeaconEdge{}} 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 = f.Clone().Count(ctx); err != nil { + if conn.TotalCount, err = b.Clone().Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -425,18 +425,18 @@ func (f *FileQuery) Paginate( return conn, nil } - f = pager.applyCursors(f, after, before) - f = pager.applyOrder(f, last != nil) + b = pager.applyCursors(b, after, before) + b = pager.applyOrder(b, last != nil) if limit := paginateLimit(first, last); limit != 0 { - f.Limit(limit) + b.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := b.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } - nodes, err := f.All(ctx) + nodes, err := b.All(ctx) if err != nil { return nil, err } @@ -445,138 +445,96 @@ func (f *FileQuery) Paginate( } var ( - // FileOrderFieldCreatedAt orders File by created_at. - FileOrderFieldCreatedAt = &FileOrderField{ - field: file.FieldCreatedAt, - toCursor: func(f *File) Cursor { - return Cursor{ - ID: f.ID, - Value: f.CreatedAt, - } - }, - } - // FileOrderFieldLastModifiedAt orders File by last_modified_at. - FileOrderFieldLastModifiedAt = &FileOrderField{ - field: file.FieldLastModifiedAt, - toCursor: func(f *File) Cursor { - return Cursor{ - ID: f.ID, - Value: f.LastModifiedAt, - } - }, - } - // FileOrderFieldName orders File by name. - FileOrderFieldName = &FileOrderField{ - field: file.FieldName, - toCursor: func(f *File) Cursor { - return Cursor{ - ID: f.ID, - Value: f.Name, - } - }, - } - // FileOrderFieldSize orders File by size. - FileOrderFieldSize = &FileOrderField{ - field: file.FieldSize, - toCursor: func(f *File) Cursor { + // BeaconOrderFieldLastSeenAt orders Beacon by last_seen_at. + BeaconOrderFieldLastSeenAt = &BeaconOrderField{ + field: beacon.FieldLastSeenAt, + toCursor: func(b *Beacon) Cursor { return Cursor{ - ID: f.ID, - Value: f.Size, + ID: b.ID, + Value: b.LastSeenAt, } }, } ) // String implement fmt.Stringer interface. -func (f FileOrderField) String() string { +func (f BeaconOrderField) String() string { var str string switch f.field { - case file.FieldCreatedAt: - str = "CREATED_AT" - case file.FieldLastModifiedAt: - str = "LAST_MODIFIED_AT" - case file.FieldName: - str = "NAME" - case file.FieldSize: - str = "SIZE" + case beacon.FieldLastSeenAt: + str = "LAST_SEEN_AT" } return str } // MarshalGQL implements graphql.Marshaler interface. -func (f FileOrderField) MarshalGQL(w io.Writer) { +func (f BeaconOrderField) MarshalGQL(w io.Writer) { io.WriteString(w, strconv.Quote(f.String())) } // UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *FileOrderField) UnmarshalGQL(v interface{}) error { +func (f *BeaconOrderField) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { - return fmt.Errorf("FileOrderField %T must be a string", v) + return fmt.Errorf("BeaconOrderField %T must be a string", v) } switch str { - case "CREATED_AT": - *f = *FileOrderFieldCreatedAt - case "LAST_MODIFIED_AT": - *f = *FileOrderFieldLastModifiedAt - case "NAME": - *f = *FileOrderFieldName - case "SIZE": - *f = *FileOrderFieldSize + case "LAST_SEEN_AT": + *f = *BeaconOrderFieldLastSeenAt default: - return fmt.Errorf("%s is not a valid FileOrderField", str) + return fmt.Errorf("%s is not a valid BeaconOrderField", str) } return nil } -// FileOrderField defines the ordering field of File. -type FileOrderField struct { +// BeaconOrderField defines the ordering field of Beacon. +type BeaconOrderField struct { field string - toCursor func(*File) Cursor + toCursor func(*Beacon) Cursor } -// FileOrder defines the ordering of File. -type FileOrder struct { - Direction OrderDirection `json:"direction"` - Field *FileOrderField `json:"field"` +// BeaconOrder defines the ordering of Beacon. +type BeaconOrder struct { + Direction OrderDirection `json:"direction"` + Field *BeaconOrderField `json:"field"` } -// DefaultFileOrder is the default ordering of File. -var DefaultFileOrder = &FileOrder{ +// DefaultBeaconOrder is the default ordering of Beacon. +var DefaultBeaconOrder = &BeaconOrder{ Direction: OrderDirectionAsc, - Field: &FileOrderField{ - field: file.FieldID, - toCursor: func(f *File) Cursor { - return Cursor{ID: f.ID} + Field: &BeaconOrderField{ + field: beacon.FieldID, + toCursor: func(b *Beacon) Cursor { + return Cursor{ID: b.ID} }, }, } -// ToEdge converts File into FileEdge. -func (f *File) ToEdge(order *FileOrder) *FileEdge { +// ToEdge converts Beacon into BeaconEdge. +func (b *Beacon) ToEdge(order *BeaconOrder) *BeaconEdge { if order == nil { - order = DefaultFileOrder + order = DefaultBeaconOrder } - return &FileEdge{ - Node: f, - Cursor: order.Field.toCursor(f), + return &BeaconEdge{ + Node: b, + Cursor: order.Field.toCursor(b), } } -// JobEdge is the edge representation of Job. -type JobEdge struct { - Node *Job `json:"node"` +// FileEdge is the edge representation of File. +type FileEdge struct { + Node *File `json:"node"` Cursor Cursor `json:"cursor"` } -// JobConnection is the connection containing edges to Job. -type JobConnection struct { - Edges []*JobEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` +// FileConnection is the connection containing edges to File. +type FileConnection struct { + Edges []*FileEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` } -func (c *JobConnection) build(nodes []*Job, pager *jobPager, after *Cursor, first *int, before *Cursor, last *int) { +func (c *FileConnection) build(nodes []*File, pager *filePager, 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) { @@ -586,21 +544,21 @@ func (c *JobConnection) build(nodes []*Job, pager *jobPager, after *Cursor, firs c.PageInfo.HasPreviousPage = true nodes = nodes[:len(nodes)-1] } - var nodeAt func(int) *Job + var nodeAt func(int) *File if last != nil { n := len(nodes) - 1 - nodeAt = func(i int) *Job { + nodeAt = func(i int) *File { return nodes[n-i] } } else { - nodeAt = func(i int) *Job { + nodeAt = func(i int) *File { return nodes[i] } } - c.Edges = make([]*JobEdge, len(nodes)) + c.Edges = make([]*FileEdge, len(nodes)) for i := range nodes { node := nodeAt(i) - c.Edges[i] = &JobEdge{ + c.Edges[i] = &FileEdge{ Node: node, Cursor: pager.toCursor(node), } @@ -614,123 +572,123 @@ func (c *JobConnection) build(nodes []*Job, pager *jobPager, after *Cursor, firs } } -// JobPaginateOption enables pagination customization. -type JobPaginateOption func(*jobPager) error +// FilePaginateOption enables pagination customization. +type FilePaginateOption func(*filePager) error -// WithJobOrder configures pagination ordering. -func WithJobOrder(order *JobOrder) JobPaginateOption { +// WithFileOrder configures pagination ordering. +func WithFileOrder(order *FileOrder) FilePaginateOption { if order == nil { - order = DefaultJobOrder + order = DefaultFileOrder } o := *order - return func(pager *jobPager) error { + return func(pager *filePager) error { if err := o.Direction.Validate(); err != nil { return err } if o.Field == nil { - o.Field = DefaultJobOrder.Field + o.Field = DefaultFileOrder.Field } pager.order = &o return nil } } -// WithJobFilter configures pagination filter. -func WithJobFilter(filter func(*JobQuery) (*JobQuery, error)) JobPaginateOption { - return func(pager *jobPager) error { +// WithFileFilter configures pagination filter. +func WithFileFilter(filter func(*FileQuery) (*FileQuery, error)) FilePaginateOption { + return func(pager *filePager) error { if filter == nil { - return errors.New("JobQuery filter cannot be nil") + return errors.New("FileQuery filter cannot be nil") } pager.filter = filter return nil } } -type jobPager struct { - order *JobOrder - filter func(*JobQuery) (*JobQuery, error) +type filePager struct { + order *FileOrder + filter func(*FileQuery) (*FileQuery, error) } -func newJobPager(opts []JobPaginateOption) (*jobPager, error) { - pager := &jobPager{} +func newFilePager(opts []FilePaginateOption) (*filePager, error) { + pager := &filePager{} for _, opt := range opts { if err := opt(pager); err != nil { return nil, err } } if pager.order == nil { - pager.order = DefaultJobOrder + pager.order = DefaultFileOrder } return pager, nil } -func (p *jobPager) applyFilter(query *JobQuery) (*JobQuery, error) { +func (p *filePager) applyFilter(query *FileQuery) (*FileQuery, error) { if p.filter != nil { return p.filter(query) } return query, nil } -func (p *jobPager) toCursor(j *Job) Cursor { - return p.order.Field.toCursor(j) +func (p *filePager) toCursor(f *File) Cursor { + return p.order.Field.toCursor(f) } -func (p *jobPager) applyCursors(query *JobQuery, after, before *Cursor) *JobQuery { +func (p *filePager) applyCursors(query *FileQuery, after, before *Cursor) *FileQuery { for _, predicate := range cursorsToPredicates( p.order.Direction, after, before, - p.order.Field.field, DefaultJobOrder.Field.field, + p.order.Field.field, DefaultFileOrder.Field.field, ) { query = query.Where(predicate) } return query } -func (p *jobPager) applyOrder(query *JobQuery, reverse bool) *JobQuery { +func (p *filePager) applyOrder(query *FileQuery, reverse bool) *FileQuery { direction := p.order.Direction if reverse { direction = direction.reverse() } query = query.Order(direction.orderFunc(p.order.Field.field)) - if p.order.Field != DefaultJobOrder.Field { - query = query.Order(direction.orderFunc(DefaultJobOrder.Field.field)) + if p.order.Field != DefaultFileOrder.Field { + query = query.Order(direction.orderFunc(DefaultFileOrder.Field.field)) } return query } -func (p *jobPager) orderExpr(reverse bool) sql.Querier { +func (p *filePager) orderExpr(reverse bool) sql.Querier { direction := p.order.Direction if reverse { direction = direction.reverse() } return sql.ExprFunc(func(b *sql.Builder) { b.Ident(p.order.Field.field).Pad().WriteString(string(direction)) - if p.order.Field != DefaultJobOrder.Field { - b.Comma().Ident(DefaultJobOrder.Field.field).Pad().WriteString(string(direction)) + if p.order.Field != DefaultFileOrder.Field { + b.Comma().Ident(DefaultFileOrder.Field.field).Pad().WriteString(string(direction)) } }) } -// Paginate executes the query and returns a relay based cursor connection to Job. -func (j *JobQuery) Paginate( +// Paginate executes the query and returns a relay based cursor connection to File. +func (f *FileQuery) Paginate( ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...JobPaginateOption, -) (*JobConnection, error) { + before *Cursor, last *int, opts ...FilePaginateOption, +) (*FileConnection, error) { if err := validateFirstLast(first, last); err != nil { return nil, err } - pager, err := newJobPager(opts) + pager, err := newFilePager(opts) if err != nil { return nil, err } - if j, err = pager.applyFilter(j); err != nil { + if f, err = pager.applyFilter(f); err != nil { return nil, err } - conn := &JobConnection{Edges: []*JobEdge{}} + conn := &FileConnection{Edges: []*FileEdge{}} 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 = j.Clone().Count(ctx); err != nil { + if conn.TotalCount, err = f.Clone().Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -741,18 +699,18 @@ func (j *JobQuery) Paginate( return conn, nil } - j = pager.applyCursors(j, after, before) - j = pager.applyOrder(j, last != nil) + f = pager.applyCursors(f, after, before) + f = pager.applyOrder(f, last != nil) if limit := paginateLimit(first, last); limit != 0 { - j.Limit(limit) + f.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := j.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } - nodes, err := j.All(ctx) + nodes, err := f.All(ctx) if err != nil { return nil, err } @@ -761,124 +719,138 @@ func (j *JobQuery) Paginate( } var ( - // JobOrderFieldCreatedAt orders Job by created_at. - JobOrderFieldCreatedAt = &JobOrderField{ - field: job.FieldCreatedAt, - toCursor: func(j *Job) Cursor { + // FileOrderFieldCreatedAt orders File by created_at. + FileOrderFieldCreatedAt = &FileOrderField{ + field: file.FieldCreatedAt, + toCursor: func(f *File) Cursor { return Cursor{ - ID: j.ID, - Value: j.CreatedAt, + ID: f.ID, + Value: f.CreatedAt, } }, } - // JobOrderFieldLastModifiedAt orders Job by last_modified_at. - JobOrderFieldLastModifiedAt = &JobOrderField{ - field: job.FieldLastModifiedAt, - toCursor: func(j *Job) Cursor { + // FileOrderFieldLastModifiedAt orders File by last_modified_at. + FileOrderFieldLastModifiedAt = &FileOrderField{ + field: file.FieldLastModifiedAt, + toCursor: func(f *File) Cursor { return Cursor{ - ID: j.ID, - Value: j.LastModifiedAt, + ID: f.ID, + Value: f.LastModifiedAt, } }, } - // JobOrderFieldName orders Job by name. - JobOrderFieldName = &JobOrderField{ - field: job.FieldName, - toCursor: func(j *Job) Cursor { + // FileOrderFieldName orders File by name. + FileOrderFieldName = &FileOrderField{ + field: file.FieldName, + toCursor: func(f *File) Cursor { return Cursor{ - ID: j.ID, - Value: j.Name, + ID: f.ID, + Value: f.Name, + } + }, + } + // FileOrderFieldSize orders File by size. + FileOrderFieldSize = &FileOrderField{ + field: file.FieldSize, + toCursor: func(f *File) Cursor { + return Cursor{ + ID: f.ID, + Value: f.Size, } }, } ) // String implement fmt.Stringer interface. -func (f JobOrderField) String() string { +func (f FileOrderField) String() string { var str string switch f.field { - case job.FieldCreatedAt: + case file.FieldCreatedAt: str = "CREATED_AT" - case job.FieldLastModifiedAt: + case file.FieldLastModifiedAt: str = "LAST_MODIFIED_AT" - case job.FieldName: + case file.FieldName: str = "NAME" + case file.FieldSize: + str = "SIZE" } return str } // MarshalGQL implements graphql.Marshaler interface. -func (f JobOrderField) MarshalGQL(w io.Writer) { +func (f FileOrderField) MarshalGQL(w io.Writer) { io.WriteString(w, strconv.Quote(f.String())) } // UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *JobOrderField) UnmarshalGQL(v interface{}) error { +func (f *FileOrderField) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { - return fmt.Errorf("JobOrderField %T must be a string", v) + return fmt.Errorf("FileOrderField %T must be a string", v) } switch str { case "CREATED_AT": - *f = *JobOrderFieldCreatedAt + *f = *FileOrderFieldCreatedAt case "LAST_MODIFIED_AT": - *f = *JobOrderFieldLastModifiedAt + *f = *FileOrderFieldLastModifiedAt case "NAME": - *f = *JobOrderFieldName + *f = *FileOrderFieldName + case "SIZE": + *f = *FileOrderFieldSize default: - return fmt.Errorf("%s is not a valid JobOrderField", str) + return fmt.Errorf("%s is not a valid FileOrderField", str) } return nil } -// JobOrderField defines the ordering field of Job. -type JobOrderField struct { +// FileOrderField defines the ordering field of File. +type FileOrderField struct { field string - toCursor func(*Job) Cursor + toCursor func(*File) Cursor } -// JobOrder defines the ordering of Job. -type JobOrder struct { - Direction OrderDirection `json:"direction"` - Field *JobOrderField `json:"field"` +// FileOrder defines the ordering of File. +type FileOrder struct { + Direction OrderDirection `json:"direction"` + Field *FileOrderField `json:"field"` } -// DefaultJobOrder is the default ordering of Job. -var DefaultJobOrder = &JobOrder{ +// DefaultFileOrder is the default ordering of File. +var DefaultFileOrder = &FileOrder{ Direction: OrderDirectionAsc, - Field: &JobOrderField{ - field: job.FieldID, - toCursor: func(j *Job) Cursor { - return Cursor{ID: j.ID} + Field: &FileOrderField{ + field: file.FieldID, + toCursor: func(f *File) Cursor { + return Cursor{ID: f.ID} }, }, } -// ToEdge converts Job into JobEdge. -func (j *Job) ToEdge(order *JobOrder) *JobEdge { +// ToEdge converts File into FileEdge. +func (f *File) ToEdge(order *FileOrder) *FileEdge { if order == nil { - order = DefaultJobOrder + order = DefaultFileOrder } - return &JobEdge{ - Node: j, - Cursor: order.Field.toCursor(j), + return &FileEdge{ + Node: f, + Cursor: order.Field.toCursor(f), } } -// SessionEdge is the edge representation of Session. -type SessionEdge struct { - Node *Session `json:"node"` - Cursor Cursor `json:"cursor"` +// QuestEdge is the edge representation of Quest. +type QuestEdge struct { + Node *Quest `json:"node"` + Cursor Cursor `json:"cursor"` } -// SessionConnection is the connection containing edges to Session. -type SessionConnection struct { - Edges []*SessionEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` +// QuestConnection is the connection containing edges to Quest. +type QuestConnection struct { + Edges []*QuestEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` } -func (c *SessionConnection) build(nodes []*Session, pager *sessionPager, after *Cursor, first *int, before *Cursor, last *int) { +func (c *QuestConnection) build(nodes []*Quest, pager *questPager, 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) { @@ -888,21 +860,21 @@ func (c *SessionConnection) build(nodes []*Session, pager *sessionPager, after * c.PageInfo.HasPreviousPage = true nodes = nodes[:len(nodes)-1] } - var nodeAt func(int) *Session + var nodeAt func(int) *Quest if last != nil { n := len(nodes) - 1 - nodeAt = func(i int) *Session { + nodeAt = func(i int) *Quest { return nodes[n-i] } } else { - nodeAt = func(i int) *Session { + nodeAt = func(i int) *Quest { return nodes[i] } } - c.Edges = make([]*SessionEdge, len(nodes)) + c.Edges = make([]*QuestEdge, len(nodes)) for i := range nodes { node := nodeAt(i) - c.Edges[i] = &SessionEdge{ + c.Edges[i] = &QuestEdge{ Node: node, Cursor: pager.toCursor(node), } @@ -916,123 +888,123 @@ func (c *SessionConnection) build(nodes []*Session, pager *sessionPager, after * } } -// SessionPaginateOption enables pagination customization. -type SessionPaginateOption func(*sessionPager) error +// QuestPaginateOption enables pagination customization. +type QuestPaginateOption func(*questPager) error -// WithSessionOrder configures pagination ordering. -func WithSessionOrder(order *SessionOrder) SessionPaginateOption { +// WithQuestOrder configures pagination ordering. +func WithQuestOrder(order *QuestOrder) QuestPaginateOption { if order == nil { - order = DefaultSessionOrder + order = DefaultQuestOrder } o := *order - return func(pager *sessionPager) error { + return func(pager *questPager) error { if err := o.Direction.Validate(); err != nil { return err } if o.Field == nil { - o.Field = DefaultSessionOrder.Field + o.Field = DefaultQuestOrder.Field } pager.order = &o return nil } } -// WithSessionFilter configures pagination filter. -func WithSessionFilter(filter func(*SessionQuery) (*SessionQuery, error)) SessionPaginateOption { - return func(pager *sessionPager) error { +// WithQuestFilter configures pagination filter. +func WithQuestFilter(filter func(*QuestQuery) (*QuestQuery, error)) QuestPaginateOption { + return func(pager *questPager) error { if filter == nil { - return errors.New("SessionQuery filter cannot be nil") + return errors.New("QuestQuery filter cannot be nil") } pager.filter = filter return nil } } -type sessionPager struct { - order *SessionOrder - filter func(*SessionQuery) (*SessionQuery, error) +type questPager struct { + order *QuestOrder + filter func(*QuestQuery) (*QuestQuery, error) } -func newSessionPager(opts []SessionPaginateOption) (*sessionPager, error) { - pager := &sessionPager{} +func newQuestPager(opts []QuestPaginateOption) (*questPager, error) { + pager := &questPager{} for _, opt := range opts { if err := opt(pager); err != nil { return nil, err } } if pager.order == nil { - pager.order = DefaultSessionOrder + pager.order = DefaultQuestOrder } return pager, nil } -func (p *sessionPager) applyFilter(query *SessionQuery) (*SessionQuery, error) { +func (p *questPager) applyFilter(query *QuestQuery) (*QuestQuery, error) { if p.filter != nil { return p.filter(query) } return query, nil } -func (p *sessionPager) toCursor(s *Session) Cursor { - return p.order.Field.toCursor(s) +func (p *questPager) toCursor(q *Quest) Cursor { + return p.order.Field.toCursor(q) } -func (p *sessionPager) applyCursors(query *SessionQuery, after, before *Cursor) *SessionQuery { +func (p *questPager) applyCursors(query *QuestQuery, after, before *Cursor) *QuestQuery { for _, predicate := range cursorsToPredicates( p.order.Direction, after, before, - p.order.Field.field, DefaultSessionOrder.Field.field, + p.order.Field.field, DefaultQuestOrder.Field.field, ) { query = query.Where(predicate) } return query } -func (p *sessionPager) applyOrder(query *SessionQuery, reverse bool) *SessionQuery { +func (p *questPager) applyOrder(query *QuestQuery, reverse bool) *QuestQuery { direction := p.order.Direction if reverse { direction = direction.reverse() } query = query.Order(direction.orderFunc(p.order.Field.field)) - if p.order.Field != DefaultSessionOrder.Field { - query = query.Order(direction.orderFunc(DefaultSessionOrder.Field.field)) + if p.order.Field != DefaultQuestOrder.Field { + query = query.Order(direction.orderFunc(DefaultQuestOrder.Field.field)) } return query } -func (p *sessionPager) orderExpr(reverse bool) sql.Querier { +func (p *questPager) orderExpr(reverse bool) sql.Querier { direction := p.order.Direction if reverse { direction = direction.reverse() } return sql.ExprFunc(func(b *sql.Builder) { b.Ident(p.order.Field.field).Pad().WriteString(string(direction)) - if p.order.Field != DefaultSessionOrder.Field { - b.Comma().Ident(DefaultSessionOrder.Field.field).Pad().WriteString(string(direction)) + if p.order.Field != DefaultQuestOrder.Field { + b.Comma().Ident(DefaultQuestOrder.Field.field).Pad().WriteString(string(direction)) } }) } -// Paginate executes the query and returns a relay based cursor connection to Session. -func (s *SessionQuery) Paginate( +// Paginate executes the query and returns a relay based cursor connection to Quest. +func (q *QuestQuery) Paginate( ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...SessionPaginateOption, -) (*SessionConnection, error) { + before *Cursor, last *int, opts ...QuestPaginateOption, +) (*QuestConnection, error) { if err := validateFirstLast(first, last); err != nil { return nil, err } - pager, err := newSessionPager(opts) + pager, err := newQuestPager(opts) if err != nil { return nil, err } - if s, err = pager.applyFilter(s); err != nil { + if q, err = pager.applyFilter(q); err != nil { return nil, err } - conn := &SessionConnection{Edges: []*SessionEdge{}} + conn := &QuestConnection{Edges: []*QuestEdge{}} 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 = s.Clone().Count(ctx); err != nil { + if conn.TotalCount, err = q.Clone().Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1043,18 +1015,18 @@ func (s *SessionQuery) Paginate( return conn, nil } - s = pager.applyCursors(s, after, before) - s = pager.applyOrder(s, last != nil) + q = pager.applyCursors(q, after, before) + q = pager.applyOrder(q, last != nil) if limit := paginateLimit(first, last); limit != 0 { - s.Limit(limit) + q.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := q.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } - nodes, err := s.All(ctx) + nodes, err := q.All(ctx) if err != nil { return nil, err } @@ -1063,79 +1035,107 @@ func (s *SessionQuery) Paginate( } var ( - // SessionOrderFieldLastSeenAt orders Session by last_seen_at. - SessionOrderFieldLastSeenAt = &SessionOrderField{ - field: session.FieldLastSeenAt, - toCursor: func(s *Session) Cursor { + // QuestOrderFieldCreatedAt orders Quest by created_at. + QuestOrderFieldCreatedAt = &QuestOrderField{ + field: quest.FieldCreatedAt, + toCursor: func(q *Quest) Cursor { return Cursor{ - ID: s.ID, - Value: s.LastSeenAt, + ID: q.ID, + Value: q.CreatedAt, + } + }, + } + // QuestOrderFieldLastModifiedAt orders Quest by last_modified_at. + QuestOrderFieldLastModifiedAt = &QuestOrderField{ + field: quest.FieldLastModifiedAt, + toCursor: func(q *Quest) Cursor { + return Cursor{ + ID: q.ID, + Value: q.LastModifiedAt, + } + }, + } + // QuestOrderFieldName orders Quest by name. + QuestOrderFieldName = &QuestOrderField{ + field: quest.FieldName, + toCursor: func(q *Quest) Cursor { + return Cursor{ + ID: q.ID, + Value: q.Name, } }, } ) // String implement fmt.Stringer interface. -func (f SessionOrderField) String() string { +func (f QuestOrderField) String() string { var str string switch f.field { - case session.FieldLastSeenAt: - str = "LAST_SEEN_AT" + case quest.FieldCreatedAt: + str = "CREATED_AT" + case quest.FieldLastModifiedAt: + str = "LAST_MODIFIED_AT" + case quest.FieldName: + str = "NAME" } return str } // MarshalGQL implements graphql.Marshaler interface. -func (f SessionOrderField) MarshalGQL(w io.Writer) { +func (f QuestOrderField) MarshalGQL(w io.Writer) { io.WriteString(w, strconv.Quote(f.String())) } // UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *SessionOrderField) UnmarshalGQL(v interface{}) error { +func (f *QuestOrderField) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { - return fmt.Errorf("SessionOrderField %T must be a string", v) + return fmt.Errorf("QuestOrderField %T must be a string", v) } switch str { - case "LAST_SEEN_AT": - *f = *SessionOrderFieldLastSeenAt + case "CREATED_AT": + *f = *QuestOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *QuestOrderFieldLastModifiedAt + case "NAME": + *f = *QuestOrderFieldName default: - return fmt.Errorf("%s is not a valid SessionOrderField", str) + return fmt.Errorf("%s is not a valid QuestOrderField", str) } return nil } -// SessionOrderField defines the ordering field of Session. -type SessionOrderField struct { +// QuestOrderField defines the ordering field of Quest. +type QuestOrderField struct { field string - toCursor func(*Session) Cursor + toCursor func(*Quest) Cursor } -// SessionOrder defines the ordering of Session. -type SessionOrder struct { - Direction OrderDirection `json:"direction"` - Field *SessionOrderField `json:"field"` +// QuestOrder defines the ordering of Quest. +type QuestOrder struct { + Direction OrderDirection `json:"direction"` + Field *QuestOrderField `json:"field"` } -// DefaultSessionOrder is the default ordering of Session. -var DefaultSessionOrder = &SessionOrder{ +// DefaultQuestOrder is the default ordering of Quest. +var DefaultQuestOrder = &QuestOrder{ Direction: OrderDirectionAsc, - Field: &SessionOrderField{ - field: session.FieldID, - toCursor: func(s *Session) Cursor { - return Cursor{ID: s.ID} + Field: &QuestOrderField{ + field: quest.FieldID, + toCursor: func(q *Quest) Cursor { + return Cursor{ID: q.ID} }, }, } -// ToEdge converts Session into SessionEdge. -func (s *Session) ToEdge(order *SessionOrder) *SessionEdge { +// ToEdge converts Quest into QuestEdge. +func (q *Quest) ToEdge(order *QuestOrder) *QuestEdge { if order == nil { - order = DefaultSessionOrder + order = DefaultQuestOrder } - return &SessionEdge{ - Node: s, - Cursor: order.Field.toCursor(s), + return &QuestEdge{ + Node: q, + Cursor: order.Field.toCursor(q), } } diff --git a/tavern/ent/gql_where_input.go b/tavern/ent/gql_where_input.go index 71fa787d9..cfee3aafe 100644 --- a/tavern/ent/gql_where_input.go +++ b/tavern/ent/gql_where_input.go @@ -7,22 +7,22 @@ import ( "fmt" "time" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" "github.com/kcarretto/realm/tavern/ent/user" ) -// FileWhereInput represents a where input for filtering File queries. -type FileWhereInput struct { - Predicates []predicate.File `json:"-"` - Not *FileWhereInput `json:"not,omitempty"` - Or []*FileWhereInput `json:"or,omitempty"` - And []*FileWhereInput `json:"and,omitempty"` +// BeaconWhereInput represents a where input for filtering Beacon queries. +type BeaconWhereInput struct { + Predicates []predicate.Beacon `json:"-"` + Not *BeaconWhereInput `json:"not,omitempty"` + Or []*BeaconWhereInput `json:"or,omitempty"` + And []*BeaconWhereInput `json:"and,omitempty"` // "id" field predicates. ID *int `json:"id,omitempty"` @@ -34,26 +34,6 @@ type FileWhereInput struct { 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"` - // "name" field predicates. Name *string `json:"name,omitempty"` NameNEQ *string `json:"nameNEQ,omitempty"` @@ -69,45 +49,146 @@ type FileWhereInput struct { NameEqualFold *string `json:"nameEqualFold,omitempty"` NameContainsFold *string `json:"nameContainsFold,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"` + // "principal" field predicates. + Principal *string `json:"principal,omitempty"` + PrincipalNEQ *string `json:"principalNEQ,omitempty"` + PrincipalIn []string `json:"principalIn,omitempty"` + PrincipalNotIn []string `json:"principalNotIn,omitempty"` + PrincipalGT *string `json:"principalGT,omitempty"` + PrincipalGTE *string `json:"principalGTE,omitempty"` + PrincipalLT *string `json:"principalLT,omitempty"` + PrincipalLTE *string `json:"principalLTE,omitempty"` + PrincipalContains *string `json:"principalContains,omitempty"` + PrincipalHasPrefix *string `json:"principalHasPrefix,omitempty"` + PrincipalHasSuffix *string `json:"principalHasSuffix,omitempty"` + PrincipalIsNil bool `json:"principalIsNil,omitempty"` + PrincipalNotNil bool `json:"principalNotNil,omitempty"` + PrincipalEqualFold *string `json:"principalEqualFold,omitempty"` + PrincipalContainsFold *string `json:"principalContainsFold,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"` - HashEqualFold *string `json:"hashEqualFold,omitempty"` - HashContainsFold *string `json:"hashContainsFold,omitempty"` + // "hostname" field predicates. + Hostname *string `json:"hostname,omitempty"` + HostnameNEQ *string `json:"hostnameNEQ,omitempty"` + HostnameIn []string `json:"hostnameIn,omitempty"` + HostnameNotIn []string `json:"hostnameNotIn,omitempty"` + HostnameGT *string `json:"hostnameGT,omitempty"` + HostnameGTE *string `json:"hostnameGTE,omitempty"` + HostnameLT *string `json:"hostnameLT,omitempty"` + HostnameLTE *string `json:"hostnameLTE,omitempty"` + HostnameContains *string `json:"hostnameContains,omitempty"` + HostnameHasPrefix *string `json:"hostnameHasPrefix,omitempty"` + HostnameHasSuffix *string `json:"hostnameHasSuffix,omitempty"` + HostnameIsNil bool `json:"hostnameIsNil,omitempty"` + HostnameNotNil bool `json:"hostnameNotNil,omitempty"` + HostnameEqualFold *string `json:"hostnameEqualFold,omitempty"` + HostnameContainsFold *string `json:"hostnameContainsFold,omitempty"` + + // "identifier" field predicates. + Identifier *string `json:"identifier,omitempty"` + IdentifierNEQ *string `json:"identifierNEQ,omitempty"` + IdentifierIn []string `json:"identifierIn,omitempty"` + IdentifierNotIn []string `json:"identifierNotIn,omitempty"` + IdentifierGT *string `json:"identifierGT,omitempty"` + IdentifierGTE *string `json:"identifierGTE,omitempty"` + IdentifierLT *string `json:"identifierLT,omitempty"` + IdentifierLTE *string `json:"identifierLTE,omitempty"` + IdentifierContains *string `json:"identifierContains,omitempty"` + IdentifierHasPrefix *string `json:"identifierHasPrefix,omitempty"` + IdentifierHasSuffix *string `json:"identifierHasSuffix,omitempty"` + IdentifierEqualFold *string `json:"identifierEqualFold,omitempty"` + IdentifierContainsFold *string `json:"identifierContainsFold,omitempty"` + + // "agent_identifier" field predicates. + AgentIdentifier *string `json:"agentIdentifier,omitempty"` + AgentIdentifierNEQ *string `json:"agentIdentifierNEQ,omitempty"` + AgentIdentifierIn []string `json:"agentIdentifierIn,omitempty"` + AgentIdentifierNotIn []string `json:"agentIdentifierNotIn,omitempty"` + AgentIdentifierGT *string `json:"agentIdentifierGT,omitempty"` + AgentIdentifierGTE *string `json:"agentIdentifierGTE,omitempty"` + AgentIdentifierLT *string `json:"agentIdentifierLT,omitempty"` + AgentIdentifierLTE *string `json:"agentIdentifierLTE,omitempty"` + AgentIdentifierContains *string `json:"agentIdentifierContains,omitempty"` + AgentIdentifierHasPrefix *string `json:"agentIdentifierHasPrefix,omitempty"` + AgentIdentifierHasSuffix *string `json:"agentIdentifierHasSuffix,omitempty"` + AgentIdentifierIsNil bool `json:"agentIdentifierIsNil,omitempty"` + AgentIdentifierNotNil bool `json:"agentIdentifierNotNil,omitempty"` + AgentIdentifierEqualFold *string `json:"agentIdentifierEqualFold,omitempty"` + AgentIdentifierContainsFold *string `json:"agentIdentifierContainsFold,omitempty"` + + // "host_identifier" field predicates. + HostIdentifier *string `json:"hostIdentifier,omitempty"` + HostIdentifierNEQ *string `json:"hostIdentifierNEQ,omitempty"` + HostIdentifierIn []string `json:"hostIdentifierIn,omitempty"` + HostIdentifierNotIn []string `json:"hostIdentifierNotIn,omitempty"` + HostIdentifierGT *string `json:"hostIdentifierGT,omitempty"` + HostIdentifierGTE *string `json:"hostIdentifierGTE,omitempty"` + HostIdentifierLT *string `json:"hostIdentifierLT,omitempty"` + HostIdentifierLTE *string `json:"hostIdentifierLTE,omitempty"` + HostIdentifierContains *string `json:"hostIdentifierContains,omitempty"` + HostIdentifierHasPrefix *string `json:"hostIdentifierHasPrefix,omitempty"` + HostIdentifierHasSuffix *string `json:"hostIdentifierHasSuffix,omitempty"` + HostIdentifierIsNil bool `json:"hostIdentifierIsNil,omitempty"` + HostIdentifierNotNil bool `json:"hostIdentifierNotNil,omitempty"` + HostIdentifierEqualFold *string `json:"hostIdentifierEqualFold,omitempty"` + HostIdentifierContainsFold *string `json:"hostIdentifierContainsFold,omitempty"` + + // "host_primary_ip" field predicates. + HostPrimaryIP *string `json:"hostPrimaryIP,omitempty"` + HostPrimaryIPNEQ *string `json:"hostPrimaryIPNEQ,omitempty"` + HostPrimaryIPIn []string `json:"hostPrimaryIPIn,omitempty"` + HostPrimaryIPNotIn []string `json:"hostPrimaryIPNotIn,omitempty"` + HostPrimaryIPGT *string `json:"hostPrimaryIPGT,omitempty"` + HostPrimaryIPGTE *string `json:"hostPrimaryIPGTE,omitempty"` + HostPrimaryIPLT *string `json:"hostPrimaryIPLT,omitempty"` + HostPrimaryIPLTE *string `json:"hostPrimaryIPLTE,omitempty"` + HostPrimaryIPContains *string `json:"hostPrimaryIPContains,omitempty"` + HostPrimaryIPHasPrefix *string `json:"hostPrimaryIPHasPrefix,omitempty"` + HostPrimaryIPHasSuffix *string `json:"hostPrimaryIPHasSuffix,omitempty"` + HostPrimaryIPIsNil bool `json:"hostPrimaryIPIsNil,omitempty"` + HostPrimaryIPNotNil bool `json:"hostPrimaryIPNotNil,omitempty"` + HostPrimaryIPEqualFold *string `json:"hostPrimaryIPEqualFold,omitempty"` + HostPrimaryIPContainsFold *string `json:"hostPrimaryIPContainsFold,omitempty"` + + // "host_platform" field predicates. + HostPlatform *beacon.HostPlatform `json:"hostPlatform,omitempty"` + HostPlatformNEQ *beacon.HostPlatform `json:"hostPlatformNEQ,omitempty"` + HostPlatformIn []beacon.HostPlatform `json:"hostPlatformIn,omitempty"` + HostPlatformNotIn []beacon.HostPlatform `json:"hostPlatformNotIn,omitempty"` + + // "last_seen_at" field predicates. + LastSeenAt *time.Time `json:"lastSeenAt,omitempty"` + LastSeenAtNEQ *time.Time `json:"lastSeenAtNEQ,omitempty"` + LastSeenAtIn []time.Time `json:"lastSeenAtIn,omitempty"` + LastSeenAtNotIn []time.Time `json:"lastSeenAtNotIn,omitempty"` + LastSeenAtGT *time.Time `json:"lastSeenAtGT,omitempty"` + LastSeenAtGTE *time.Time `json:"lastSeenAtGTE,omitempty"` + LastSeenAtLT *time.Time `json:"lastSeenAtLT,omitempty"` + LastSeenAtLTE *time.Time `json:"lastSeenAtLTE,omitempty"` + LastSeenAtIsNil bool `json:"lastSeenAtIsNil,omitempty"` + LastSeenAtNotNil bool `json:"lastSeenAtNotNil,omitempty"` + + // "tags" edge predicates. + HasTags *bool `json:"hasTags,omitempty"` + HasTagsWith []*TagWhereInput `json:"hasTagsWith,omitempty"` + + // "tasks" edge predicates. + HasTasks *bool `json:"hasTasks,omitempty"` + HasTasksWith []*TaskWhereInput `json:"hasTasksWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *FileWhereInput) AddPredicates(predicates ...predicate.File) { +func (i *BeaconWhereInput) AddPredicates(predicates ...predicate.Beacon) { i.Predicates = append(i.Predicates, predicates...) } -// Filter applies the FileWhereInput filter on the FileQuery builder. -func (i *FileWhereInput) Filter(q *FileQuery) (*FileQuery, error) { +// Filter applies the BeaconWhereInput filter on the BeaconQuery builder. +func (i *BeaconWhereInput) Filter(q *BeaconQuery) (*BeaconQuery, error) { if i == nil { return q, nil } p, err := i.P() if err != nil { - if err == ErrEmptyFileWhereInput { + if err == ErrEmptyBeaconWhereInput { return q, nil } return nil, err @@ -115,19 +196,19 @@ func (i *FileWhereInput) Filter(q *FileQuery) (*FileQuery, error) { return q.Where(p), nil } -// ErrEmptyFileWhereInput is returned in case the FileWhereInput is empty. -var ErrEmptyFileWhereInput = errors.New("ent: empty predicate FileWhereInput") +// ErrEmptyBeaconWhereInput is returned in case the BeaconWhereInput is empty. +var ErrEmptyBeaconWhereInput = errors.New("ent: empty predicate BeaconWhereInput") -// P returns a predicate for filtering files. +// P returns a predicate for filtering beacons. // An error is returned if the input is empty or invalid. -func (i *FileWhereInput) P() (predicate.File, error) { - var predicates []predicate.File +func (i *BeaconWhereInput) P() (predicate.Beacon, error) { + var predicates []predicate.Beacon if i.Not != nil { p, err := i.Not.P() if err != nil { return nil, fmt.Errorf("%w: field 'not'", err) } - predicates = append(predicates, file.Not(p)) + predicates = append(predicates, beacon.Not(p)) } switch n := len(i.Or); { case n == 1: @@ -137,7 +218,7 @@ func (i *FileWhereInput) P() (predicate.File, error) { } predicates = append(predicates, p) case n > 1: - or := make([]predicate.File, 0, n) + or := make([]predicate.Beacon, 0, n) for _, w := range i.Or { p, err := w.P() if err != nil { @@ -145,7 +226,7 @@ func (i *FileWhereInput) P() (predicate.File, error) { } or = append(or, p) } - predicates = append(predicates, file.Or(or...)) + predicates = append(predicates, beacon.Or(or...)) } switch n := len(i.And); { case n == 1: @@ -155,7 +236,7 @@ func (i *FileWhereInput) P() (predicate.File, error) { } predicates = append(predicates, p) case n > 1: - and := make([]predicate.File, 0, n) + and := make([]predicate.Beacon, 0, n) for _, w := range i.And { p, err := w.P() if err != nil { @@ -163,548 +244,401 @@ func (i *FileWhereInput) P() (predicate.File, error) { } and = append(and, p) } - predicates = append(predicates, file.And(and...)) + predicates = append(predicates, beacon.And(and...)) } predicates = append(predicates, i.Predicates...) if i.ID != nil { - predicates = append(predicates, file.IDEQ(*i.ID)) + predicates = append(predicates, beacon.IDEQ(*i.ID)) } if i.IDNEQ != nil { - predicates = append(predicates, file.IDNEQ(*i.IDNEQ)) + predicates = append(predicates, beacon.IDNEQ(*i.IDNEQ)) } if len(i.IDIn) > 0 { - predicates = append(predicates, file.IDIn(i.IDIn...)) + predicates = append(predicates, beacon.IDIn(i.IDIn...)) } if len(i.IDNotIn) > 0 { - predicates = append(predicates, file.IDNotIn(i.IDNotIn...)) + predicates = append(predicates, beacon.IDNotIn(i.IDNotIn...)) } if i.IDGT != nil { - predicates = append(predicates, file.IDGT(*i.IDGT)) + predicates = append(predicates, beacon.IDGT(*i.IDGT)) } if i.IDGTE != nil { - predicates = append(predicates, file.IDGTE(*i.IDGTE)) + predicates = append(predicates, beacon.IDGTE(*i.IDGTE)) } if i.IDLT != nil { - predicates = append(predicates, file.IDLT(*i.IDLT)) + predicates = append(predicates, beacon.IDLT(*i.IDLT)) } if i.IDLTE != nil { - predicates = append(predicates, file.IDLTE(*i.IDLTE)) - } - if i.CreatedAt != nil { - predicates = append(predicates, file.CreatedAtEQ(*i.CreatedAt)) - } - if i.CreatedAtNEQ != nil { - predicates = append(predicates, file.CreatedAtNEQ(*i.CreatedAtNEQ)) - } - if len(i.CreatedAtIn) > 0 { - predicates = append(predicates, file.CreatedAtIn(i.CreatedAtIn...)) - } - if len(i.CreatedAtNotIn) > 0 { - predicates = append(predicates, file.CreatedAtNotIn(i.CreatedAtNotIn...)) - } - if i.CreatedAtGT != nil { - predicates = append(predicates, file.CreatedAtGT(*i.CreatedAtGT)) - } - if i.CreatedAtGTE != nil { - predicates = append(predicates, file.CreatedAtGTE(*i.CreatedAtGTE)) - } - if i.CreatedAtLT != nil { - predicates = append(predicates, file.CreatedAtLT(*i.CreatedAtLT)) - } - if i.CreatedAtLTE != nil { - predicates = append(predicates, file.CreatedAtLTE(*i.CreatedAtLTE)) - } - if i.LastModifiedAt != nil { - predicates = append(predicates, file.LastModifiedAtEQ(*i.LastModifiedAt)) - } - if i.LastModifiedAtNEQ != nil { - predicates = append(predicates, file.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) - } - if len(i.LastModifiedAtIn) > 0 { - predicates = append(predicates, file.LastModifiedAtIn(i.LastModifiedAtIn...)) - } - if len(i.LastModifiedAtNotIn) > 0 { - predicates = append(predicates, file.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) - } - if i.LastModifiedAtGT != nil { - predicates = append(predicates, file.LastModifiedAtGT(*i.LastModifiedAtGT)) - } - if i.LastModifiedAtGTE != nil { - predicates = append(predicates, file.LastModifiedAtGTE(*i.LastModifiedAtGTE)) - } - if i.LastModifiedAtLT != nil { - predicates = append(predicates, file.LastModifiedAtLT(*i.LastModifiedAtLT)) - } - if i.LastModifiedAtLTE != nil { - predicates = append(predicates, file.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + predicates = append(predicates, beacon.IDLTE(*i.IDLTE)) } if i.Name != nil { - predicates = append(predicates, file.NameEQ(*i.Name)) + predicates = append(predicates, beacon.NameEQ(*i.Name)) } if i.NameNEQ != nil { - predicates = append(predicates, file.NameNEQ(*i.NameNEQ)) + predicates = append(predicates, beacon.NameNEQ(*i.NameNEQ)) } if len(i.NameIn) > 0 { - predicates = append(predicates, file.NameIn(i.NameIn...)) + predicates = append(predicates, beacon.NameIn(i.NameIn...)) } if len(i.NameNotIn) > 0 { - predicates = append(predicates, file.NameNotIn(i.NameNotIn...)) + predicates = append(predicates, beacon.NameNotIn(i.NameNotIn...)) } if i.NameGT != nil { - predicates = append(predicates, file.NameGT(*i.NameGT)) + predicates = append(predicates, beacon.NameGT(*i.NameGT)) } if i.NameGTE != nil { - predicates = append(predicates, file.NameGTE(*i.NameGTE)) + predicates = append(predicates, beacon.NameGTE(*i.NameGTE)) } if i.NameLT != nil { - predicates = append(predicates, file.NameLT(*i.NameLT)) + predicates = append(predicates, beacon.NameLT(*i.NameLT)) } if i.NameLTE != nil { - predicates = append(predicates, file.NameLTE(*i.NameLTE)) + predicates = append(predicates, beacon.NameLTE(*i.NameLTE)) } if i.NameContains != nil { - predicates = append(predicates, file.NameContains(*i.NameContains)) + predicates = append(predicates, beacon.NameContains(*i.NameContains)) } if i.NameHasPrefix != nil { - predicates = append(predicates, file.NameHasPrefix(*i.NameHasPrefix)) + predicates = append(predicates, beacon.NameHasPrefix(*i.NameHasPrefix)) } if i.NameHasSuffix != nil { - predicates = append(predicates, file.NameHasSuffix(*i.NameHasSuffix)) + predicates = append(predicates, beacon.NameHasSuffix(*i.NameHasSuffix)) } if i.NameEqualFold != nil { - predicates = append(predicates, file.NameEqualFold(*i.NameEqualFold)) + predicates = append(predicates, beacon.NameEqualFold(*i.NameEqualFold)) } if i.NameContainsFold != nil { - predicates = append(predicates, file.NameContainsFold(*i.NameContainsFold)) + predicates = append(predicates, beacon.NameContainsFold(*i.NameContainsFold)) } - if i.Size != nil { - predicates = append(predicates, file.SizeEQ(*i.Size)) + if i.Principal != nil { + predicates = append(predicates, beacon.PrincipalEQ(*i.Principal)) } - if i.SizeNEQ != nil { - predicates = append(predicates, file.SizeNEQ(*i.SizeNEQ)) + if i.PrincipalNEQ != nil { + predicates = append(predicates, beacon.PrincipalNEQ(*i.PrincipalNEQ)) } - if len(i.SizeIn) > 0 { - predicates = append(predicates, file.SizeIn(i.SizeIn...)) + if len(i.PrincipalIn) > 0 { + predicates = append(predicates, beacon.PrincipalIn(i.PrincipalIn...)) } - if len(i.SizeNotIn) > 0 { - predicates = append(predicates, file.SizeNotIn(i.SizeNotIn...)) + if len(i.PrincipalNotIn) > 0 { + predicates = append(predicates, beacon.PrincipalNotIn(i.PrincipalNotIn...)) } - if i.SizeGT != nil { - predicates = append(predicates, file.SizeGT(*i.SizeGT)) + if i.PrincipalGT != nil { + predicates = append(predicates, beacon.PrincipalGT(*i.PrincipalGT)) } - if i.SizeGTE != nil { - predicates = append(predicates, file.SizeGTE(*i.SizeGTE)) + if i.PrincipalGTE != nil { + predicates = append(predicates, beacon.PrincipalGTE(*i.PrincipalGTE)) } - if i.SizeLT != nil { - predicates = append(predicates, file.SizeLT(*i.SizeLT)) + if i.PrincipalLT != nil { + predicates = append(predicates, beacon.PrincipalLT(*i.PrincipalLT)) } - if i.SizeLTE != nil { - predicates = append(predicates, file.SizeLTE(*i.SizeLTE)) + if i.PrincipalLTE != nil { + predicates = append(predicates, beacon.PrincipalLTE(*i.PrincipalLTE)) } - if i.Hash != nil { - predicates = append(predicates, file.HashEQ(*i.Hash)) + if i.PrincipalContains != nil { + predicates = append(predicates, beacon.PrincipalContains(*i.PrincipalContains)) } - if i.HashNEQ != nil { - predicates = append(predicates, file.HashNEQ(*i.HashNEQ)) + if i.PrincipalHasPrefix != nil { + predicates = append(predicates, beacon.PrincipalHasPrefix(*i.PrincipalHasPrefix)) } - if len(i.HashIn) > 0 { - predicates = append(predicates, file.HashIn(i.HashIn...)) + if i.PrincipalHasSuffix != nil { + predicates = append(predicates, beacon.PrincipalHasSuffix(*i.PrincipalHasSuffix)) } - if len(i.HashNotIn) > 0 { - predicates = append(predicates, file.HashNotIn(i.HashNotIn...)) + if i.PrincipalIsNil { + predicates = append(predicates, beacon.PrincipalIsNil()) } - if i.HashGT != nil { - predicates = append(predicates, file.HashGT(*i.HashGT)) + if i.PrincipalNotNil { + predicates = append(predicates, beacon.PrincipalNotNil()) } - if i.HashGTE != nil { - predicates = append(predicates, file.HashGTE(*i.HashGTE)) + if i.PrincipalEqualFold != nil { + predicates = append(predicates, beacon.PrincipalEqualFold(*i.PrincipalEqualFold)) } - if i.HashLT != nil { - predicates = append(predicates, file.HashLT(*i.HashLT)) + if i.PrincipalContainsFold != nil { + predicates = append(predicates, beacon.PrincipalContainsFold(*i.PrincipalContainsFold)) } - if i.HashLTE != nil { - predicates = append(predicates, file.HashLTE(*i.HashLTE)) + if i.Hostname != nil { + predicates = append(predicates, beacon.HostnameEQ(*i.Hostname)) } - if i.HashContains != nil { - predicates = append(predicates, file.HashContains(*i.HashContains)) + if i.HostnameNEQ != nil { + predicates = append(predicates, beacon.HostnameNEQ(*i.HostnameNEQ)) } - if i.HashHasPrefix != nil { - predicates = append(predicates, file.HashHasPrefix(*i.HashHasPrefix)) + if len(i.HostnameIn) > 0 { + predicates = append(predicates, beacon.HostnameIn(i.HostnameIn...)) } - if i.HashHasSuffix != nil { - predicates = append(predicates, file.HashHasSuffix(*i.HashHasSuffix)) + if len(i.HostnameNotIn) > 0 { + predicates = append(predicates, beacon.HostnameNotIn(i.HostnameNotIn...)) } - if i.HashEqualFold != nil { - predicates = append(predicates, file.HashEqualFold(*i.HashEqualFold)) + if i.HostnameGT != nil { + predicates = append(predicates, beacon.HostnameGT(*i.HostnameGT)) } - if i.HashContainsFold != nil { - predicates = append(predicates, file.HashContainsFold(*i.HashContainsFold)) + if i.HostnameGTE != nil { + predicates = append(predicates, beacon.HostnameGTE(*i.HostnameGTE)) } - - switch len(predicates) { - case 0: - return nil, ErrEmptyFileWhereInput - case 1: - return predicates[0], nil - default: - return file.And(predicates...), nil + if i.HostnameLT != nil { + predicates = append(predicates, beacon.HostnameLT(*i.HostnameLT)) } -} - -// JobWhereInput represents a where input for filtering Job queries. -type JobWhereInput struct { - Predicates []predicate.Job `json:"-"` - Not *JobWhereInput `json:"not,omitempty"` - Or []*JobWhereInput `json:"or,omitempty"` - And []*JobWhereInput `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"` - - // "name" field predicates. - Name *string `json:"name,omitempty"` - NameNEQ *string `json:"nameNEQ,omitempty"` - NameIn []string `json:"nameIn,omitempty"` - NameNotIn []string `json:"nameNotIn,omitempty"` - NameGT *string `json:"nameGT,omitempty"` - NameGTE *string `json:"nameGTE,omitempty"` - NameLT *string `json:"nameLT,omitempty"` - NameLTE *string `json:"nameLTE,omitempty"` - NameContains *string `json:"nameContains,omitempty"` - NameHasPrefix *string `json:"nameHasPrefix,omitempty"` - NameHasSuffix *string `json:"nameHasSuffix,omitempty"` - NameEqualFold *string `json:"nameEqualFold,omitempty"` - NameContainsFold *string `json:"nameContainsFold,omitempty"` - - // "parameters" field predicates. - Parameters *string `json:"parameters,omitempty"` - ParametersNEQ *string `json:"parametersNEQ,omitempty"` - ParametersIn []string `json:"parametersIn,omitempty"` - ParametersNotIn []string `json:"parametersNotIn,omitempty"` - ParametersGT *string `json:"parametersGT,omitempty"` - ParametersGTE *string `json:"parametersGTE,omitempty"` - ParametersLT *string `json:"parametersLT,omitempty"` - ParametersLTE *string `json:"parametersLTE,omitempty"` - ParametersContains *string `json:"parametersContains,omitempty"` - ParametersHasPrefix *string `json:"parametersHasPrefix,omitempty"` - ParametersHasSuffix *string `json:"parametersHasSuffix,omitempty"` - ParametersIsNil bool `json:"parametersIsNil,omitempty"` - ParametersNotNil bool `json:"parametersNotNil,omitempty"` - ParametersEqualFold *string `json:"parametersEqualFold,omitempty"` - ParametersContainsFold *string `json:"parametersContainsFold,omitempty"` - - // "tome" edge predicates. - HasTome *bool `json:"hasTome,omitempty"` - HasTomeWith []*TomeWhereInput `json:"hasTomeWith,omitempty"` - - // "bundle" edge predicates. - HasBundle *bool `json:"hasBundle,omitempty"` - HasBundleWith []*FileWhereInput `json:"hasBundleWith,omitempty"` - - // "tasks" edge predicates. - HasTasks *bool `json:"hasTasks,omitempty"` - HasTasksWith []*TaskWhereInput `json:"hasTasksWith,omitempty"` - - // "creator" edge predicates. - HasCreator *bool `json:"hasCreator,omitempty"` - HasCreatorWith []*UserWhereInput `json:"hasCreatorWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *JobWhereInput) AddPredicates(predicates ...predicate.Job) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the JobWhereInput filter on the JobQuery builder. -func (i *JobWhereInput) Filter(q *JobQuery) (*JobQuery, error) { - if i == nil { - return q, nil + if i.HostnameLTE != nil { + predicates = append(predicates, beacon.HostnameLTE(*i.HostnameLTE)) } - p, err := i.P() - if err != nil { - if err == ErrEmptyJobWhereInput { - return q, nil - } - return nil, err + if i.HostnameContains != nil { + predicates = append(predicates, beacon.HostnameContains(*i.HostnameContains)) } - return q.Where(p), nil -} - -// ErrEmptyJobWhereInput is returned in case the JobWhereInput is empty. -var ErrEmptyJobWhereInput = errors.New("ent: empty predicate JobWhereInput") - -// P returns a predicate for filtering jobs. -// An error is returned if the input is empty or invalid. -func (i *JobWhereInput) P() (predicate.Job, error) { - var predicates []predicate.Job - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, job.Not(p)) + if i.HostnameHasPrefix != nil { + predicates = append(predicates, beacon.HostnameHasPrefix(*i.HostnameHasPrefix)) } - 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.Job, 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, job.Or(or...)) + if i.HostnameHasSuffix != nil { + predicates = append(predicates, beacon.HostnameHasSuffix(*i.HostnameHasSuffix)) } - 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.Job, 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, job.And(and...)) + if i.HostnameIsNil { + predicates = append(predicates, beacon.HostnameIsNil()) } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, job.IDEQ(*i.ID)) + if i.HostnameNotNil { + predicates = append(predicates, beacon.HostnameNotNil()) } - if i.IDNEQ != nil { - predicates = append(predicates, job.IDNEQ(*i.IDNEQ)) + if i.HostnameEqualFold != nil { + predicates = append(predicates, beacon.HostnameEqualFold(*i.HostnameEqualFold)) } - if len(i.IDIn) > 0 { - predicates = append(predicates, job.IDIn(i.IDIn...)) + if i.HostnameContainsFold != nil { + predicates = append(predicates, beacon.HostnameContainsFold(*i.HostnameContainsFold)) } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, job.IDNotIn(i.IDNotIn...)) + if i.Identifier != nil { + predicates = append(predicates, beacon.IdentifierEQ(*i.Identifier)) } - if i.IDGT != nil { - predicates = append(predicates, job.IDGT(*i.IDGT)) + if i.IdentifierNEQ != nil { + predicates = append(predicates, beacon.IdentifierNEQ(*i.IdentifierNEQ)) } - if i.IDGTE != nil { - predicates = append(predicates, job.IDGTE(*i.IDGTE)) + if len(i.IdentifierIn) > 0 { + predicates = append(predicates, beacon.IdentifierIn(i.IdentifierIn...)) } - if i.IDLT != nil { - predicates = append(predicates, job.IDLT(*i.IDLT)) + if len(i.IdentifierNotIn) > 0 { + predicates = append(predicates, beacon.IdentifierNotIn(i.IdentifierNotIn...)) } - if i.IDLTE != nil { - predicates = append(predicates, job.IDLTE(*i.IDLTE)) + if i.IdentifierGT != nil { + predicates = append(predicates, beacon.IdentifierGT(*i.IdentifierGT)) } - if i.CreatedAt != nil { - predicates = append(predicates, job.CreatedAtEQ(*i.CreatedAt)) + if i.IdentifierGTE != nil { + predicates = append(predicates, beacon.IdentifierGTE(*i.IdentifierGTE)) } - if i.CreatedAtNEQ != nil { - predicates = append(predicates, job.CreatedAtNEQ(*i.CreatedAtNEQ)) + if i.IdentifierLT != nil { + predicates = append(predicates, beacon.IdentifierLT(*i.IdentifierLT)) } - if len(i.CreatedAtIn) > 0 { - predicates = append(predicates, job.CreatedAtIn(i.CreatedAtIn...)) + if i.IdentifierLTE != nil { + predicates = append(predicates, beacon.IdentifierLTE(*i.IdentifierLTE)) } - if len(i.CreatedAtNotIn) > 0 { - predicates = append(predicates, job.CreatedAtNotIn(i.CreatedAtNotIn...)) + if i.IdentifierContains != nil { + predicates = append(predicates, beacon.IdentifierContains(*i.IdentifierContains)) } - if i.CreatedAtGT != nil { - predicates = append(predicates, job.CreatedAtGT(*i.CreatedAtGT)) + if i.IdentifierHasPrefix != nil { + predicates = append(predicates, beacon.IdentifierHasPrefix(*i.IdentifierHasPrefix)) } - if i.CreatedAtGTE != nil { - predicates = append(predicates, job.CreatedAtGTE(*i.CreatedAtGTE)) + if i.IdentifierHasSuffix != nil { + predicates = append(predicates, beacon.IdentifierHasSuffix(*i.IdentifierHasSuffix)) } - if i.CreatedAtLT != nil { - predicates = append(predicates, job.CreatedAtLT(*i.CreatedAtLT)) + if i.IdentifierEqualFold != nil { + predicates = append(predicates, beacon.IdentifierEqualFold(*i.IdentifierEqualFold)) } - if i.CreatedAtLTE != nil { - predicates = append(predicates, job.CreatedAtLTE(*i.CreatedAtLTE)) + if i.IdentifierContainsFold != nil { + predicates = append(predicates, beacon.IdentifierContainsFold(*i.IdentifierContainsFold)) } - if i.LastModifiedAt != nil { - predicates = append(predicates, job.LastModifiedAtEQ(*i.LastModifiedAt)) + if i.AgentIdentifier != nil { + predicates = append(predicates, beacon.AgentIdentifierEQ(*i.AgentIdentifier)) } - if i.LastModifiedAtNEQ != nil { - predicates = append(predicates, job.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + if i.AgentIdentifierNEQ != nil { + predicates = append(predicates, beacon.AgentIdentifierNEQ(*i.AgentIdentifierNEQ)) } - if len(i.LastModifiedAtIn) > 0 { - predicates = append(predicates, job.LastModifiedAtIn(i.LastModifiedAtIn...)) + if len(i.AgentIdentifierIn) > 0 { + predicates = append(predicates, beacon.AgentIdentifierIn(i.AgentIdentifierIn...)) + } + if len(i.AgentIdentifierNotIn) > 0 { + predicates = append(predicates, beacon.AgentIdentifierNotIn(i.AgentIdentifierNotIn...)) + } + if i.AgentIdentifierGT != nil { + predicates = append(predicates, beacon.AgentIdentifierGT(*i.AgentIdentifierGT)) + } + if i.AgentIdentifierGTE != nil { + predicates = append(predicates, beacon.AgentIdentifierGTE(*i.AgentIdentifierGTE)) + } + if i.AgentIdentifierLT != nil { + predicates = append(predicates, beacon.AgentIdentifierLT(*i.AgentIdentifierLT)) + } + if i.AgentIdentifierLTE != nil { + predicates = append(predicates, beacon.AgentIdentifierLTE(*i.AgentIdentifierLTE)) + } + if i.AgentIdentifierContains != nil { + predicates = append(predicates, beacon.AgentIdentifierContains(*i.AgentIdentifierContains)) + } + if i.AgentIdentifierHasPrefix != nil { + predicates = append(predicates, beacon.AgentIdentifierHasPrefix(*i.AgentIdentifierHasPrefix)) + } + if i.AgentIdentifierHasSuffix != nil { + predicates = append(predicates, beacon.AgentIdentifierHasSuffix(*i.AgentIdentifierHasSuffix)) + } + if i.AgentIdentifierIsNil { + predicates = append(predicates, beacon.AgentIdentifierIsNil()) + } + if i.AgentIdentifierNotNil { + predicates = append(predicates, beacon.AgentIdentifierNotNil()) + } + if i.AgentIdentifierEqualFold != nil { + predicates = append(predicates, beacon.AgentIdentifierEqualFold(*i.AgentIdentifierEqualFold)) + } + if i.AgentIdentifierContainsFold != nil { + predicates = append(predicates, beacon.AgentIdentifierContainsFold(*i.AgentIdentifierContainsFold)) + } + if i.HostIdentifier != nil { + predicates = append(predicates, beacon.HostIdentifierEQ(*i.HostIdentifier)) + } + if i.HostIdentifierNEQ != nil { + predicates = append(predicates, beacon.HostIdentifierNEQ(*i.HostIdentifierNEQ)) + } + if len(i.HostIdentifierIn) > 0 { + predicates = append(predicates, beacon.HostIdentifierIn(i.HostIdentifierIn...)) + } + if len(i.HostIdentifierNotIn) > 0 { + predicates = append(predicates, beacon.HostIdentifierNotIn(i.HostIdentifierNotIn...)) + } + if i.HostIdentifierGT != nil { + predicates = append(predicates, beacon.HostIdentifierGT(*i.HostIdentifierGT)) + } + if i.HostIdentifierGTE != nil { + predicates = append(predicates, beacon.HostIdentifierGTE(*i.HostIdentifierGTE)) + } + if i.HostIdentifierLT != nil { + predicates = append(predicates, beacon.HostIdentifierLT(*i.HostIdentifierLT)) + } + if i.HostIdentifierLTE != nil { + predicates = append(predicates, beacon.HostIdentifierLTE(*i.HostIdentifierLTE)) + } + if i.HostIdentifierContains != nil { + predicates = append(predicates, beacon.HostIdentifierContains(*i.HostIdentifierContains)) } - if len(i.LastModifiedAtNotIn) > 0 { - predicates = append(predicates, job.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + if i.HostIdentifierHasPrefix != nil { + predicates = append(predicates, beacon.HostIdentifierHasPrefix(*i.HostIdentifierHasPrefix)) } - if i.LastModifiedAtGT != nil { - predicates = append(predicates, job.LastModifiedAtGT(*i.LastModifiedAtGT)) + if i.HostIdentifierHasSuffix != nil { + predicates = append(predicates, beacon.HostIdentifierHasSuffix(*i.HostIdentifierHasSuffix)) } - if i.LastModifiedAtGTE != nil { - predicates = append(predicates, job.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + if i.HostIdentifierIsNil { + predicates = append(predicates, beacon.HostIdentifierIsNil()) } - if i.LastModifiedAtLT != nil { - predicates = append(predicates, job.LastModifiedAtLT(*i.LastModifiedAtLT)) + if i.HostIdentifierNotNil { + predicates = append(predicates, beacon.HostIdentifierNotNil()) } - if i.LastModifiedAtLTE != nil { - predicates = append(predicates, job.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + if i.HostIdentifierEqualFold != nil { + predicates = append(predicates, beacon.HostIdentifierEqualFold(*i.HostIdentifierEqualFold)) } - if i.Name != nil { - predicates = append(predicates, job.NameEQ(*i.Name)) + if i.HostIdentifierContainsFold != nil { + predicates = append(predicates, beacon.HostIdentifierContainsFold(*i.HostIdentifierContainsFold)) } - if i.NameNEQ != nil { - predicates = append(predicates, job.NameNEQ(*i.NameNEQ)) + if i.HostPrimaryIP != nil { + predicates = append(predicates, beacon.HostPrimaryIPEQ(*i.HostPrimaryIP)) } - if len(i.NameIn) > 0 { - predicates = append(predicates, job.NameIn(i.NameIn...)) + if i.HostPrimaryIPNEQ != nil { + predicates = append(predicates, beacon.HostPrimaryIPNEQ(*i.HostPrimaryIPNEQ)) } - if len(i.NameNotIn) > 0 { - predicates = append(predicates, job.NameNotIn(i.NameNotIn...)) + if len(i.HostPrimaryIPIn) > 0 { + predicates = append(predicates, beacon.HostPrimaryIPIn(i.HostPrimaryIPIn...)) } - if i.NameGT != nil { - predicates = append(predicates, job.NameGT(*i.NameGT)) + if len(i.HostPrimaryIPNotIn) > 0 { + predicates = append(predicates, beacon.HostPrimaryIPNotIn(i.HostPrimaryIPNotIn...)) } - if i.NameGTE != nil { - predicates = append(predicates, job.NameGTE(*i.NameGTE)) + if i.HostPrimaryIPGT != nil { + predicates = append(predicates, beacon.HostPrimaryIPGT(*i.HostPrimaryIPGT)) } - if i.NameLT != nil { - predicates = append(predicates, job.NameLT(*i.NameLT)) + if i.HostPrimaryIPGTE != nil { + predicates = append(predicates, beacon.HostPrimaryIPGTE(*i.HostPrimaryIPGTE)) } - if i.NameLTE != nil { - predicates = append(predicates, job.NameLTE(*i.NameLTE)) + if i.HostPrimaryIPLT != nil { + predicates = append(predicates, beacon.HostPrimaryIPLT(*i.HostPrimaryIPLT)) } - if i.NameContains != nil { - predicates = append(predicates, job.NameContains(*i.NameContains)) + if i.HostPrimaryIPLTE != nil { + predicates = append(predicates, beacon.HostPrimaryIPLTE(*i.HostPrimaryIPLTE)) } - if i.NameHasPrefix != nil { - predicates = append(predicates, job.NameHasPrefix(*i.NameHasPrefix)) + if i.HostPrimaryIPContains != nil { + predicates = append(predicates, beacon.HostPrimaryIPContains(*i.HostPrimaryIPContains)) } - if i.NameHasSuffix != nil { - predicates = append(predicates, job.NameHasSuffix(*i.NameHasSuffix)) + if i.HostPrimaryIPHasPrefix != nil { + predicates = append(predicates, beacon.HostPrimaryIPHasPrefix(*i.HostPrimaryIPHasPrefix)) } - if i.NameEqualFold != nil { - predicates = append(predicates, job.NameEqualFold(*i.NameEqualFold)) + if i.HostPrimaryIPHasSuffix != nil { + predicates = append(predicates, beacon.HostPrimaryIPHasSuffix(*i.HostPrimaryIPHasSuffix)) } - if i.NameContainsFold != nil { - predicates = append(predicates, job.NameContainsFold(*i.NameContainsFold)) + if i.HostPrimaryIPIsNil { + predicates = append(predicates, beacon.HostPrimaryIPIsNil()) } - if i.Parameters != nil { - predicates = append(predicates, job.ParametersEQ(*i.Parameters)) + if i.HostPrimaryIPNotNil { + predicates = append(predicates, beacon.HostPrimaryIPNotNil()) } - if i.ParametersNEQ != nil { - predicates = append(predicates, job.ParametersNEQ(*i.ParametersNEQ)) + if i.HostPrimaryIPEqualFold != nil { + predicates = append(predicates, beacon.HostPrimaryIPEqualFold(*i.HostPrimaryIPEqualFold)) } - if len(i.ParametersIn) > 0 { - predicates = append(predicates, job.ParametersIn(i.ParametersIn...)) + if i.HostPrimaryIPContainsFold != nil { + predicates = append(predicates, beacon.HostPrimaryIPContainsFold(*i.HostPrimaryIPContainsFold)) } - if len(i.ParametersNotIn) > 0 { - predicates = append(predicates, job.ParametersNotIn(i.ParametersNotIn...)) + if i.HostPlatform != nil { + predicates = append(predicates, beacon.HostPlatformEQ(*i.HostPlatform)) } - if i.ParametersGT != nil { - predicates = append(predicates, job.ParametersGT(*i.ParametersGT)) + if i.HostPlatformNEQ != nil { + predicates = append(predicates, beacon.HostPlatformNEQ(*i.HostPlatformNEQ)) } - if i.ParametersGTE != nil { - predicates = append(predicates, job.ParametersGTE(*i.ParametersGTE)) + if len(i.HostPlatformIn) > 0 { + predicates = append(predicates, beacon.HostPlatformIn(i.HostPlatformIn...)) } - if i.ParametersLT != nil { - predicates = append(predicates, job.ParametersLT(*i.ParametersLT)) + if len(i.HostPlatformNotIn) > 0 { + predicates = append(predicates, beacon.HostPlatformNotIn(i.HostPlatformNotIn...)) } - if i.ParametersLTE != nil { - predicates = append(predicates, job.ParametersLTE(*i.ParametersLTE)) + if i.LastSeenAt != nil { + predicates = append(predicates, beacon.LastSeenAtEQ(*i.LastSeenAt)) } - if i.ParametersContains != nil { - predicates = append(predicates, job.ParametersContains(*i.ParametersContains)) + if i.LastSeenAtNEQ != nil { + predicates = append(predicates, beacon.LastSeenAtNEQ(*i.LastSeenAtNEQ)) } - if i.ParametersHasPrefix != nil { - predicates = append(predicates, job.ParametersHasPrefix(*i.ParametersHasPrefix)) + if len(i.LastSeenAtIn) > 0 { + predicates = append(predicates, beacon.LastSeenAtIn(i.LastSeenAtIn...)) } - if i.ParametersHasSuffix != nil { - predicates = append(predicates, job.ParametersHasSuffix(*i.ParametersHasSuffix)) + if len(i.LastSeenAtNotIn) > 0 { + predicates = append(predicates, beacon.LastSeenAtNotIn(i.LastSeenAtNotIn...)) } - if i.ParametersIsNil { - predicates = append(predicates, job.ParametersIsNil()) + if i.LastSeenAtGT != nil { + predicates = append(predicates, beacon.LastSeenAtGT(*i.LastSeenAtGT)) } - if i.ParametersNotNil { - predicates = append(predicates, job.ParametersNotNil()) + if i.LastSeenAtGTE != nil { + predicates = append(predicates, beacon.LastSeenAtGTE(*i.LastSeenAtGTE)) } - if i.ParametersEqualFold != nil { - predicates = append(predicates, job.ParametersEqualFold(*i.ParametersEqualFold)) + if i.LastSeenAtLT != nil { + predicates = append(predicates, beacon.LastSeenAtLT(*i.LastSeenAtLT)) } - if i.ParametersContainsFold != nil { - predicates = append(predicates, job.ParametersContainsFold(*i.ParametersContainsFold)) + if i.LastSeenAtLTE != nil { + predicates = append(predicates, beacon.LastSeenAtLTE(*i.LastSeenAtLTE)) } - - if i.HasTome != nil { - p := job.HasTome() - if !*i.HasTome { - p = job.Not(p) - } - predicates = append(predicates, p) + if i.LastSeenAtIsNil { + predicates = append(predicates, beacon.LastSeenAtIsNil()) } - if len(i.HasTomeWith) > 0 { - with := make([]predicate.Tome, 0, len(i.HasTomeWith)) - for _, w := range i.HasTomeWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasTomeWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, job.HasTomeWith(with...)) + if i.LastSeenAtNotNil { + predicates = append(predicates, beacon.LastSeenAtNotNil()) } - if i.HasBundle != nil { - p := job.HasBundle() - if !*i.HasBundle { - p = job.Not(p) + + if i.HasTags != nil { + p := beacon.HasTags() + if !*i.HasTags { + p = beacon.Not(p) } predicates = append(predicates, p) } - if len(i.HasBundleWith) > 0 { - with := make([]predicate.File, 0, len(i.HasBundleWith)) - for _, w := range i.HasBundleWith { + if len(i.HasTagsWith) > 0 { + with := make([]predicate.Tag, 0, len(i.HasTagsWith)) + for _, w := range i.HasTagsWith { p, err := w.P() if err != nil { - return nil, fmt.Errorf("%w: field 'HasBundleWith'", err) + return nil, fmt.Errorf("%w: field 'HasTagsWith'", err) } with = append(with, p) } - predicates = append(predicates, job.HasBundleWith(with...)) + predicates = append(predicates, beacon.HasTagsWith(with...)) } if i.HasTasks != nil { - p := job.HasTasks() + p := beacon.HasTasks() if !*i.HasTasks { - p = job.Not(p) + p = beacon.Not(p) } predicates = append(predicates, p) } @@ -717,42 +651,24 @@ func (i *JobWhereInput) P() (predicate.Job, error) { } with = append(with, p) } - predicates = append(predicates, job.HasTasksWith(with...)) - } - if i.HasCreator != nil { - p := job.HasCreator() - if !*i.HasCreator { - p = job.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasCreatorWith) > 0 { - with := make([]predicate.User, 0, len(i.HasCreatorWith)) - for _, w := range i.HasCreatorWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasCreatorWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, job.HasCreatorWith(with...)) + predicates = append(predicates, beacon.HasTasksWith(with...)) } switch len(predicates) { case 0: - return nil, ErrEmptyJobWhereInput + return nil, ErrEmptyBeaconWhereInput case 1: return predicates[0], nil default: - return job.And(predicates...), nil + return beacon.And(predicates...), nil } } -// SessionWhereInput represents a where input for filtering Session queries. -type SessionWhereInput struct { - Predicates []predicate.Session `json:"-"` - Not *SessionWhereInput `json:"not,omitempty"` - Or []*SessionWhereInput `json:"or,omitempty"` - And []*SessionWhereInput `json:"and,omitempty"` +// FileWhereInput represents a where input for filtering File queries. +type FileWhereInput struct { + Predicates []predicate.File `json:"-"` + Not *FileWhereInput `json:"not,omitempty"` + Or []*FileWhereInput `json:"or,omitempty"` + And []*FileWhereInput `json:"and,omitempty"` // "id" field predicates. ID *int `json:"id,omitempty"` @@ -764,6 +680,26 @@ type SessionWhereInput struct { 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"` + // "name" field predicates. Name *string `json:"name,omitempty"` NameNEQ *string `json:"nameNEQ,omitempty"` @@ -773,152 +709,51 @@ type SessionWhereInput struct { NameGTE *string `json:"nameGTE,omitempty"` NameLT *string `json:"nameLT,omitempty"` NameLTE *string `json:"nameLTE,omitempty"` - NameContains *string `json:"nameContains,omitempty"` - NameHasPrefix *string `json:"nameHasPrefix,omitempty"` - NameHasSuffix *string `json:"nameHasSuffix,omitempty"` - NameEqualFold *string `json:"nameEqualFold,omitempty"` - NameContainsFold *string `json:"nameContainsFold,omitempty"` - - // "principal" field predicates. - Principal *string `json:"principal,omitempty"` - PrincipalNEQ *string `json:"principalNEQ,omitempty"` - PrincipalIn []string `json:"principalIn,omitempty"` - PrincipalNotIn []string `json:"principalNotIn,omitempty"` - PrincipalGT *string `json:"principalGT,omitempty"` - PrincipalGTE *string `json:"principalGTE,omitempty"` - PrincipalLT *string `json:"principalLT,omitempty"` - PrincipalLTE *string `json:"principalLTE,omitempty"` - PrincipalContains *string `json:"principalContains,omitempty"` - PrincipalHasPrefix *string `json:"principalHasPrefix,omitempty"` - PrincipalHasSuffix *string `json:"principalHasSuffix,omitempty"` - PrincipalIsNil bool `json:"principalIsNil,omitempty"` - PrincipalNotNil bool `json:"principalNotNil,omitempty"` - PrincipalEqualFold *string `json:"principalEqualFold,omitempty"` - PrincipalContainsFold *string `json:"principalContainsFold,omitempty"` - - // "hostname" field predicates. - Hostname *string `json:"hostname,omitempty"` - HostnameNEQ *string `json:"hostnameNEQ,omitempty"` - HostnameIn []string `json:"hostnameIn,omitempty"` - HostnameNotIn []string `json:"hostnameNotIn,omitempty"` - HostnameGT *string `json:"hostnameGT,omitempty"` - HostnameGTE *string `json:"hostnameGTE,omitempty"` - HostnameLT *string `json:"hostnameLT,omitempty"` - HostnameLTE *string `json:"hostnameLTE,omitempty"` - HostnameContains *string `json:"hostnameContains,omitempty"` - HostnameHasPrefix *string `json:"hostnameHasPrefix,omitempty"` - HostnameHasSuffix *string `json:"hostnameHasSuffix,omitempty"` - HostnameIsNil bool `json:"hostnameIsNil,omitempty"` - HostnameNotNil bool `json:"hostnameNotNil,omitempty"` - HostnameEqualFold *string `json:"hostnameEqualFold,omitempty"` - HostnameContainsFold *string `json:"hostnameContainsFold,omitempty"` - - // "identifier" field predicates. - Identifier *string `json:"identifier,omitempty"` - IdentifierNEQ *string `json:"identifierNEQ,omitempty"` - IdentifierIn []string `json:"identifierIn,omitempty"` - IdentifierNotIn []string `json:"identifierNotIn,omitempty"` - IdentifierGT *string `json:"identifierGT,omitempty"` - IdentifierGTE *string `json:"identifierGTE,omitempty"` - IdentifierLT *string `json:"identifierLT,omitempty"` - IdentifierLTE *string `json:"identifierLTE,omitempty"` - IdentifierContains *string `json:"identifierContains,omitempty"` - IdentifierHasPrefix *string `json:"identifierHasPrefix,omitempty"` - IdentifierHasSuffix *string `json:"identifierHasSuffix,omitempty"` - IdentifierEqualFold *string `json:"identifierEqualFold,omitempty"` - IdentifierContainsFold *string `json:"identifierContainsFold,omitempty"` - - // "agent_identifier" field predicates. - AgentIdentifier *string `json:"agentIdentifier,omitempty"` - AgentIdentifierNEQ *string `json:"agentIdentifierNEQ,omitempty"` - AgentIdentifierIn []string `json:"agentIdentifierIn,omitempty"` - AgentIdentifierNotIn []string `json:"agentIdentifierNotIn,omitempty"` - AgentIdentifierGT *string `json:"agentIdentifierGT,omitempty"` - AgentIdentifierGTE *string `json:"agentIdentifierGTE,omitempty"` - AgentIdentifierLT *string `json:"agentIdentifierLT,omitempty"` - AgentIdentifierLTE *string `json:"agentIdentifierLTE,omitempty"` - AgentIdentifierContains *string `json:"agentIdentifierContains,omitempty"` - AgentIdentifierHasPrefix *string `json:"agentIdentifierHasPrefix,omitempty"` - AgentIdentifierHasSuffix *string `json:"agentIdentifierHasSuffix,omitempty"` - AgentIdentifierIsNil bool `json:"agentIdentifierIsNil,omitempty"` - AgentIdentifierNotNil bool `json:"agentIdentifierNotNil,omitempty"` - AgentIdentifierEqualFold *string `json:"agentIdentifierEqualFold,omitempty"` - AgentIdentifierContainsFold *string `json:"agentIdentifierContainsFold,omitempty"` - - // "host_identifier" field predicates. - HostIdentifier *string `json:"hostIdentifier,omitempty"` - HostIdentifierNEQ *string `json:"hostIdentifierNEQ,omitempty"` - HostIdentifierIn []string `json:"hostIdentifierIn,omitempty"` - HostIdentifierNotIn []string `json:"hostIdentifierNotIn,omitempty"` - HostIdentifierGT *string `json:"hostIdentifierGT,omitempty"` - HostIdentifierGTE *string `json:"hostIdentifierGTE,omitempty"` - HostIdentifierLT *string `json:"hostIdentifierLT,omitempty"` - HostIdentifierLTE *string `json:"hostIdentifierLTE,omitempty"` - HostIdentifierContains *string `json:"hostIdentifierContains,omitempty"` - HostIdentifierHasPrefix *string `json:"hostIdentifierHasPrefix,omitempty"` - HostIdentifierHasSuffix *string `json:"hostIdentifierHasSuffix,omitempty"` - HostIdentifierIsNil bool `json:"hostIdentifierIsNil,omitempty"` - HostIdentifierNotNil bool `json:"hostIdentifierNotNil,omitempty"` - HostIdentifierEqualFold *string `json:"hostIdentifierEqualFold,omitempty"` - HostIdentifierContainsFold *string `json:"hostIdentifierContainsFold,omitempty"` - - // "host_primary_ip" field predicates. - HostPrimaryIP *string `json:"hostPrimaryIP,omitempty"` - HostPrimaryIPNEQ *string `json:"hostPrimaryIPNEQ,omitempty"` - HostPrimaryIPIn []string `json:"hostPrimaryIPIn,omitempty"` - HostPrimaryIPNotIn []string `json:"hostPrimaryIPNotIn,omitempty"` - HostPrimaryIPGT *string `json:"hostPrimaryIPGT,omitempty"` - HostPrimaryIPGTE *string `json:"hostPrimaryIPGTE,omitempty"` - HostPrimaryIPLT *string `json:"hostPrimaryIPLT,omitempty"` - HostPrimaryIPLTE *string `json:"hostPrimaryIPLTE,omitempty"` - HostPrimaryIPContains *string `json:"hostPrimaryIPContains,omitempty"` - HostPrimaryIPHasPrefix *string `json:"hostPrimaryIPHasPrefix,omitempty"` - HostPrimaryIPHasSuffix *string `json:"hostPrimaryIPHasSuffix,omitempty"` - HostPrimaryIPIsNil bool `json:"hostPrimaryIPIsNil,omitempty"` - HostPrimaryIPNotNil bool `json:"hostPrimaryIPNotNil,omitempty"` - HostPrimaryIPEqualFold *string `json:"hostPrimaryIPEqualFold,omitempty"` - HostPrimaryIPContainsFold *string `json:"hostPrimaryIPContainsFold,omitempty"` - - // "host_platform" field predicates. - HostPlatform *session.HostPlatform `json:"hostPlatform,omitempty"` - HostPlatformNEQ *session.HostPlatform `json:"hostPlatformNEQ,omitempty"` - HostPlatformIn []session.HostPlatform `json:"hostPlatformIn,omitempty"` - HostPlatformNotIn []session.HostPlatform `json:"hostPlatformNotIn,omitempty"` - - // "last_seen_at" field predicates. - LastSeenAt *time.Time `json:"lastSeenAt,omitempty"` - LastSeenAtNEQ *time.Time `json:"lastSeenAtNEQ,omitempty"` - LastSeenAtIn []time.Time `json:"lastSeenAtIn,omitempty"` - LastSeenAtNotIn []time.Time `json:"lastSeenAtNotIn,omitempty"` - LastSeenAtGT *time.Time `json:"lastSeenAtGT,omitempty"` - LastSeenAtGTE *time.Time `json:"lastSeenAtGTE,omitempty"` - LastSeenAtLT *time.Time `json:"lastSeenAtLT,omitempty"` - LastSeenAtLTE *time.Time `json:"lastSeenAtLTE,omitempty"` - LastSeenAtIsNil bool `json:"lastSeenAtIsNil,omitempty"` - LastSeenAtNotNil bool `json:"lastSeenAtNotNil,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` - // "tags" edge predicates. - HasTags *bool `json:"hasTags,omitempty"` - HasTagsWith []*TagWhereInput `json:"hasTagsWith,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"` - // "tasks" edge predicates. - HasTasks *bool `json:"hasTasks,omitempty"` - HasTasksWith []*TaskWhereInput `json:"hasTasksWith,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"` + HashEqualFold *string `json:"hashEqualFold,omitempty"` + HashContainsFold *string `json:"hashContainsFold,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *SessionWhereInput) AddPredicates(predicates ...predicate.Session) { +func (i *FileWhereInput) AddPredicates(predicates ...predicate.File) { i.Predicates = append(i.Predicates, predicates...) } -// Filter applies the SessionWhereInput filter on the SessionQuery builder. -func (i *SessionWhereInput) Filter(q *SessionQuery) (*SessionQuery, error) { +// Filter applies the FileWhereInput filter on the FileQuery builder. +func (i *FileWhereInput) Filter(q *FileQuery) (*FileQuery, error) { if i == nil { return q, nil } p, err := i.P() if err != nil { - if err == ErrEmptySessionWhereInput { + if err == ErrEmptyFileWhereInput { return q, nil } return nil, err @@ -926,19 +761,19 @@ func (i *SessionWhereInput) Filter(q *SessionQuery) (*SessionQuery, error) { return q.Where(p), nil } -// ErrEmptySessionWhereInput is returned in case the SessionWhereInput is empty. -var ErrEmptySessionWhereInput = errors.New("ent: empty predicate SessionWhereInput") +// ErrEmptyFileWhereInput is returned in case the FileWhereInput is empty. +var ErrEmptyFileWhereInput = errors.New("ent: empty predicate FileWhereInput") -// P returns a predicate for filtering sessions. +// P returns a predicate for filtering files. // An error is returned if the input is empty or invalid. -func (i *SessionWhereInput) P() (predicate.Session, error) { - var predicates []predicate.Session +func (i *FileWhereInput) P() (predicate.File, error) { + var predicates []predicate.File if i.Not != nil { p, err := i.Not.P() if err != nil { return nil, fmt.Errorf("%w: field 'not'", err) } - predicates = append(predicates, session.Not(p)) + predicates = append(predicates, file.Not(p)) } switch n := len(i.Or); { case n == 1: @@ -948,7 +783,7 @@ func (i *SessionWhereInput) P() (predicate.Session, error) { } predicates = append(predicates, p) case n > 1: - or := make([]predicate.Session, 0, n) + or := make([]predicate.File, 0, n) for _, w := range i.Or { p, err := w.P() if err != nil { @@ -956,7 +791,7 @@ func (i *SessionWhereInput) P() (predicate.Session, error) { } or = append(or, p) } - predicates = append(predicates, session.Or(or...)) + predicates = append(predicates, file.Or(or...)) } switch n := len(i.And); { case n == 1: @@ -966,7 +801,7 @@ func (i *SessionWhereInput) P() (predicate.Session, error) { } predicates = append(predicates, p) case n > 1: - and := make([]predicate.Session, 0, n) + and := make([]predicate.File, 0, n) for _, w := range i.And { p, err := w.P() if err != nil { @@ -974,401 +809,548 @@ func (i *SessionWhereInput) P() (predicate.Session, error) { } and = append(and, p) } - predicates = append(predicates, session.And(and...)) + predicates = append(predicates, file.And(and...)) } predicates = append(predicates, i.Predicates...) if i.ID != nil { - predicates = append(predicates, session.IDEQ(*i.ID)) + predicates = append(predicates, file.IDEQ(*i.ID)) } if i.IDNEQ != nil { - predicates = append(predicates, session.IDNEQ(*i.IDNEQ)) + predicates = append(predicates, file.IDNEQ(*i.IDNEQ)) } if len(i.IDIn) > 0 { - predicates = append(predicates, session.IDIn(i.IDIn...)) + predicates = append(predicates, file.IDIn(i.IDIn...)) } if len(i.IDNotIn) > 0 { - predicates = append(predicates, session.IDNotIn(i.IDNotIn...)) + predicates = append(predicates, file.IDNotIn(i.IDNotIn...)) } if i.IDGT != nil { - predicates = append(predicates, session.IDGT(*i.IDGT)) + predicates = append(predicates, file.IDGT(*i.IDGT)) } if i.IDGTE != nil { - predicates = append(predicates, session.IDGTE(*i.IDGTE)) + predicates = append(predicates, file.IDGTE(*i.IDGTE)) } if i.IDLT != nil { - predicates = append(predicates, session.IDLT(*i.IDLT)) + predicates = append(predicates, file.IDLT(*i.IDLT)) } if i.IDLTE != nil { - predicates = append(predicates, session.IDLTE(*i.IDLTE)) - } - if i.Name != nil { - predicates = append(predicates, session.NameEQ(*i.Name)) - } - if i.NameNEQ != nil { - predicates = append(predicates, session.NameNEQ(*i.NameNEQ)) - } - if len(i.NameIn) > 0 { - predicates = append(predicates, session.NameIn(i.NameIn...)) - } - if len(i.NameNotIn) > 0 { - predicates = append(predicates, session.NameNotIn(i.NameNotIn...)) - } - if i.NameGT != nil { - predicates = append(predicates, session.NameGT(*i.NameGT)) + predicates = append(predicates, file.IDLTE(*i.IDLTE)) } - if i.NameGTE != nil { - predicates = append(predicates, session.NameGTE(*i.NameGTE)) + if i.CreatedAt != nil { + predicates = append(predicates, file.CreatedAtEQ(*i.CreatedAt)) } - if i.NameLT != nil { - predicates = append(predicates, session.NameLT(*i.NameLT)) + if i.CreatedAtNEQ != nil { + predicates = append(predicates, file.CreatedAtNEQ(*i.CreatedAtNEQ)) } - if i.NameLTE != nil { - predicates = append(predicates, session.NameLTE(*i.NameLTE)) + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, file.CreatedAtIn(i.CreatedAtIn...)) } - if i.NameContains != nil { - predicates = append(predicates, session.NameContains(*i.NameContains)) + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, file.CreatedAtNotIn(i.CreatedAtNotIn...)) } - if i.NameHasPrefix != nil { - predicates = append(predicates, session.NameHasPrefix(*i.NameHasPrefix)) + if i.CreatedAtGT != nil { + predicates = append(predicates, file.CreatedAtGT(*i.CreatedAtGT)) } - if i.NameHasSuffix != nil { - predicates = append(predicates, session.NameHasSuffix(*i.NameHasSuffix)) + if i.CreatedAtGTE != nil { + predicates = append(predicates, file.CreatedAtGTE(*i.CreatedAtGTE)) } - if i.NameEqualFold != nil { - predicates = append(predicates, session.NameEqualFold(*i.NameEqualFold)) + if i.CreatedAtLT != nil { + predicates = append(predicates, file.CreatedAtLT(*i.CreatedAtLT)) } - if i.NameContainsFold != nil { - predicates = append(predicates, session.NameContainsFold(*i.NameContainsFold)) + if i.CreatedAtLTE != nil { + predicates = append(predicates, file.CreatedAtLTE(*i.CreatedAtLTE)) } - if i.Principal != nil { - predicates = append(predicates, session.PrincipalEQ(*i.Principal)) + if i.LastModifiedAt != nil { + predicates = append(predicates, file.LastModifiedAtEQ(*i.LastModifiedAt)) } - if i.PrincipalNEQ != nil { - predicates = append(predicates, session.PrincipalNEQ(*i.PrincipalNEQ)) + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, file.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) } - if len(i.PrincipalIn) > 0 { - predicates = append(predicates, session.PrincipalIn(i.PrincipalIn...)) + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, file.LastModifiedAtIn(i.LastModifiedAtIn...)) } - if len(i.PrincipalNotIn) > 0 { - predicates = append(predicates, session.PrincipalNotIn(i.PrincipalNotIn...)) + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, file.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) } - if i.PrincipalGT != nil { - predicates = append(predicates, session.PrincipalGT(*i.PrincipalGT)) + if i.LastModifiedAtGT != nil { + predicates = append(predicates, file.LastModifiedAtGT(*i.LastModifiedAtGT)) } - if i.PrincipalGTE != nil { - predicates = append(predicates, session.PrincipalGTE(*i.PrincipalGTE)) + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, file.LastModifiedAtGTE(*i.LastModifiedAtGTE)) } - if i.PrincipalLT != nil { - predicates = append(predicates, session.PrincipalLT(*i.PrincipalLT)) + if i.LastModifiedAtLT != nil { + predicates = append(predicates, file.LastModifiedAtLT(*i.LastModifiedAtLT)) } - if i.PrincipalLTE != nil { - predicates = append(predicates, session.PrincipalLTE(*i.PrincipalLTE)) + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, file.LastModifiedAtLTE(*i.LastModifiedAtLTE)) } - if i.PrincipalContains != nil { - predicates = append(predicates, session.PrincipalContains(*i.PrincipalContains)) + if i.Name != nil { + predicates = append(predicates, file.NameEQ(*i.Name)) } - if i.PrincipalHasPrefix != nil { - predicates = append(predicates, session.PrincipalHasPrefix(*i.PrincipalHasPrefix)) + if i.NameNEQ != nil { + predicates = append(predicates, file.NameNEQ(*i.NameNEQ)) } - if i.PrincipalHasSuffix != nil { - predicates = append(predicates, session.PrincipalHasSuffix(*i.PrincipalHasSuffix)) + if len(i.NameIn) > 0 { + predicates = append(predicates, file.NameIn(i.NameIn...)) } - if i.PrincipalIsNil { - predicates = append(predicates, session.PrincipalIsNil()) + if len(i.NameNotIn) > 0 { + predicates = append(predicates, file.NameNotIn(i.NameNotIn...)) } - if i.PrincipalNotNil { - predicates = append(predicates, session.PrincipalNotNil()) + if i.NameGT != nil { + predicates = append(predicates, file.NameGT(*i.NameGT)) } - if i.PrincipalEqualFold != nil { - predicates = append(predicates, session.PrincipalEqualFold(*i.PrincipalEqualFold)) + if i.NameGTE != nil { + predicates = append(predicates, file.NameGTE(*i.NameGTE)) } - if i.PrincipalContainsFold != nil { - predicates = append(predicates, session.PrincipalContainsFold(*i.PrincipalContainsFold)) + if i.NameLT != nil { + predicates = append(predicates, file.NameLT(*i.NameLT)) } - if i.Hostname != nil { - predicates = append(predicates, session.HostnameEQ(*i.Hostname)) + if i.NameLTE != nil { + predicates = append(predicates, file.NameLTE(*i.NameLTE)) } - if i.HostnameNEQ != nil { - predicates = append(predicates, session.HostnameNEQ(*i.HostnameNEQ)) + if i.NameContains != nil { + predicates = append(predicates, file.NameContains(*i.NameContains)) } - if len(i.HostnameIn) > 0 { - predicates = append(predicates, session.HostnameIn(i.HostnameIn...)) + if i.NameHasPrefix != nil { + predicates = append(predicates, file.NameHasPrefix(*i.NameHasPrefix)) } - if len(i.HostnameNotIn) > 0 { - predicates = append(predicates, session.HostnameNotIn(i.HostnameNotIn...)) + if i.NameHasSuffix != nil { + predicates = append(predicates, file.NameHasSuffix(*i.NameHasSuffix)) } - if i.HostnameGT != nil { - predicates = append(predicates, session.HostnameGT(*i.HostnameGT)) + if i.NameEqualFold != nil { + predicates = append(predicates, file.NameEqualFold(*i.NameEqualFold)) } - if i.HostnameGTE != nil { - predicates = append(predicates, session.HostnameGTE(*i.HostnameGTE)) + if i.NameContainsFold != nil { + predicates = append(predicates, file.NameContainsFold(*i.NameContainsFold)) } - if i.HostnameLT != nil { - predicates = append(predicates, session.HostnameLT(*i.HostnameLT)) + if i.Size != nil { + predicates = append(predicates, file.SizeEQ(*i.Size)) } - if i.HostnameLTE != nil { - predicates = append(predicates, session.HostnameLTE(*i.HostnameLTE)) + if i.SizeNEQ != nil { + predicates = append(predicates, file.SizeNEQ(*i.SizeNEQ)) } - if i.HostnameContains != nil { - predicates = append(predicates, session.HostnameContains(*i.HostnameContains)) + if len(i.SizeIn) > 0 { + predicates = append(predicates, file.SizeIn(i.SizeIn...)) } - if i.HostnameHasPrefix != nil { - predicates = append(predicates, session.HostnameHasPrefix(*i.HostnameHasPrefix)) + if len(i.SizeNotIn) > 0 { + predicates = append(predicates, file.SizeNotIn(i.SizeNotIn...)) } - if i.HostnameHasSuffix != nil { - predicates = append(predicates, session.HostnameHasSuffix(*i.HostnameHasSuffix)) + if i.SizeGT != nil { + predicates = append(predicates, file.SizeGT(*i.SizeGT)) } - if i.HostnameIsNil { - predicates = append(predicates, session.HostnameIsNil()) + if i.SizeGTE != nil { + predicates = append(predicates, file.SizeGTE(*i.SizeGTE)) } - if i.HostnameNotNil { - predicates = append(predicates, session.HostnameNotNil()) + if i.SizeLT != nil { + predicates = append(predicates, file.SizeLT(*i.SizeLT)) } - if i.HostnameEqualFold != nil { - predicates = append(predicates, session.HostnameEqualFold(*i.HostnameEqualFold)) + if i.SizeLTE != nil { + predicates = append(predicates, file.SizeLTE(*i.SizeLTE)) } - if i.HostnameContainsFold != nil { - predicates = append(predicates, session.HostnameContainsFold(*i.HostnameContainsFold)) + if i.Hash != nil { + predicates = append(predicates, file.HashEQ(*i.Hash)) } - if i.Identifier != nil { - predicates = append(predicates, session.IdentifierEQ(*i.Identifier)) + if i.HashNEQ != nil { + predicates = append(predicates, file.HashNEQ(*i.HashNEQ)) } - if i.IdentifierNEQ != nil { - predicates = append(predicates, session.IdentifierNEQ(*i.IdentifierNEQ)) + if len(i.HashIn) > 0 { + predicates = append(predicates, file.HashIn(i.HashIn...)) } - if len(i.IdentifierIn) > 0 { - predicates = append(predicates, session.IdentifierIn(i.IdentifierIn...)) + if len(i.HashNotIn) > 0 { + predicates = append(predicates, file.HashNotIn(i.HashNotIn...)) } - if len(i.IdentifierNotIn) > 0 { - predicates = append(predicates, session.IdentifierNotIn(i.IdentifierNotIn...)) + if i.HashGT != nil { + predicates = append(predicates, file.HashGT(*i.HashGT)) } - if i.IdentifierGT != nil { - predicates = append(predicates, session.IdentifierGT(*i.IdentifierGT)) + if i.HashGTE != nil { + predicates = append(predicates, file.HashGTE(*i.HashGTE)) } - if i.IdentifierGTE != nil { - predicates = append(predicates, session.IdentifierGTE(*i.IdentifierGTE)) + if i.HashLT != nil { + predicates = append(predicates, file.HashLT(*i.HashLT)) } - if i.IdentifierLT != nil { - predicates = append(predicates, session.IdentifierLT(*i.IdentifierLT)) + if i.HashLTE != nil { + predicates = append(predicates, file.HashLTE(*i.HashLTE)) } - if i.IdentifierLTE != nil { - predicates = append(predicates, session.IdentifierLTE(*i.IdentifierLTE)) + if i.HashContains != nil { + predicates = append(predicates, file.HashContains(*i.HashContains)) } - if i.IdentifierContains != nil { - predicates = append(predicates, session.IdentifierContains(*i.IdentifierContains)) + if i.HashHasPrefix != nil { + predicates = append(predicates, file.HashHasPrefix(*i.HashHasPrefix)) } - if i.IdentifierHasPrefix != nil { - predicates = append(predicates, session.IdentifierHasPrefix(*i.IdentifierHasPrefix)) + if i.HashHasSuffix != nil { + predicates = append(predicates, file.HashHasSuffix(*i.HashHasSuffix)) } - if i.IdentifierHasSuffix != nil { - predicates = append(predicates, session.IdentifierHasSuffix(*i.IdentifierHasSuffix)) + if i.HashEqualFold != nil { + predicates = append(predicates, file.HashEqualFold(*i.HashEqualFold)) } - if i.IdentifierEqualFold != nil { - predicates = append(predicates, session.IdentifierEqualFold(*i.IdentifierEqualFold)) + if i.HashContainsFold != nil { + predicates = append(predicates, file.HashContainsFold(*i.HashContainsFold)) } - if i.IdentifierContainsFold != nil { - predicates = append(predicates, session.IdentifierContainsFold(*i.IdentifierContainsFold)) + + switch len(predicates) { + case 0: + return nil, ErrEmptyFileWhereInput + case 1: + return predicates[0], nil + default: + return file.And(predicates...), nil } - if i.AgentIdentifier != nil { - predicates = append(predicates, session.AgentIdentifierEQ(*i.AgentIdentifier)) +} + +// QuestWhereInput represents a where input for filtering Quest queries. +type QuestWhereInput struct { + Predicates []predicate.Quest `json:"-"` + Not *QuestWhereInput `json:"not,omitempty"` + Or []*QuestWhereInput `json:"or,omitempty"` + And []*QuestWhereInput `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"` + + // "name" field predicates. + Name *string `json:"name,omitempty"` + NameNEQ *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGT *string `json:"nameGT,omitempty"` + NameGTE *string `json:"nameGTE,omitempty"` + NameLT *string `json:"nameLT,omitempty"` + NameLTE *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` + + // "parameters" field predicates. + Parameters *string `json:"parameters,omitempty"` + ParametersNEQ *string `json:"parametersNEQ,omitempty"` + ParametersIn []string `json:"parametersIn,omitempty"` + ParametersNotIn []string `json:"parametersNotIn,omitempty"` + ParametersGT *string `json:"parametersGT,omitempty"` + ParametersGTE *string `json:"parametersGTE,omitempty"` + ParametersLT *string `json:"parametersLT,omitempty"` + ParametersLTE *string `json:"parametersLTE,omitempty"` + ParametersContains *string `json:"parametersContains,omitempty"` + ParametersHasPrefix *string `json:"parametersHasPrefix,omitempty"` + ParametersHasSuffix *string `json:"parametersHasSuffix,omitempty"` + ParametersIsNil bool `json:"parametersIsNil,omitempty"` + ParametersNotNil bool `json:"parametersNotNil,omitempty"` + ParametersEqualFold *string `json:"parametersEqualFold,omitempty"` + ParametersContainsFold *string `json:"parametersContainsFold,omitempty"` + + // "tome" edge predicates. + HasTome *bool `json:"hasTome,omitempty"` + HasTomeWith []*TomeWhereInput `json:"hasTomeWith,omitempty"` + + // "bundle" edge predicates. + HasBundle *bool `json:"hasBundle,omitempty"` + HasBundleWith []*FileWhereInput `json:"hasBundleWith,omitempty"` + + // "tasks" edge predicates. + HasTasks *bool `json:"hasTasks,omitempty"` + HasTasksWith []*TaskWhereInput `json:"hasTasksWith,omitempty"` + + // "creator" edge predicates. + HasCreator *bool `json:"hasCreator,omitempty"` + HasCreatorWith []*UserWhereInput `json:"hasCreatorWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *QuestWhereInput) AddPredicates(predicates ...predicate.Quest) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the QuestWhereInput filter on the QuestQuery builder. +func (i *QuestWhereInput) Filter(q *QuestQuery) (*QuestQuery, error) { + if i == nil { + return q, nil } - if i.AgentIdentifierNEQ != nil { - predicates = append(predicates, session.AgentIdentifierNEQ(*i.AgentIdentifierNEQ)) + p, err := i.P() + if err != nil { + if err == ErrEmptyQuestWhereInput { + return q, nil + } + return nil, err } - if len(i.AgentIdentifierIn) > 0 { - predicates = append(predicates, session.AgentIdentifierIn(i.AgentIdentifierIn...)) + return q.Where(p), nil +} + +// ErrEmptyQuestWhereInput is returned in case the QuestWhereInput is empty. +var ErrEmptyQuestWhereInput = errors.New("ent: empty predicate QuestWhereInput") + +// P returns a predicate for filtering quests. +// An error is returned if the input is empty or invalid. +func (i *QuestWhereInput) P() (predicate.Quest, error) { + var predicates []predicate.Quest + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, quest.Not(p)) } - if len(i.AgentIdentifierNotIn) > 0 { - predicates = append(predicates, session.AgentIdentifierNotIn(i.AgentIdentifierNotIn...)) + 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.Quest, 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, quest.Or(or...)) } - if i.AgentIdentifierGT != nil { - predicates = append(predicates, session.AgentIdentifierGT(*i.AgentIdentifierGT)) + 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.Quest, 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, quest.And(and...)) } - if i.AgentIdentifierGTE != nil { - predicates = append(predicates, session.AgentIdentifierGTE(*i.AgentIdentifierGTE)) + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, quest.IDEQ(*i.ID)) } - if i.AgentIdentifierLT != nil { - predicates = append(predicates, session.AgentIdentifierLT(*i.AgentIdentifierLT)) + if i.IDNEQ != nil { + predicates = append(predicates, quest.IDNEQ(*i.IDNEQ)) } - if i.AgentIdentifierLTE != nil { - predicates = append(predicates, session.AgentIdentifierLTE(*i.AgentIdentifierLTE)) + if len(i.IDIn) > 0 { + predicates = append(predicates, quest.IDIn(i.IDIn...)) } - if i.AgentIdentifierContains != nil { - predicates = append(predicates, session.AgentIdentifierContains(*i.AgentIdentifierContains)) + if len(i.IDNotIn) > 0 { + predicates = append(predicates, quest.IDNotIn(i.IDNotIn...)) } - if i.AgentIdentifierHasPrefix != nil { - predicates = append(predicates, session.AgentIdentifierHasPrefix(*i.AgentIdentifierHasPrefix)) + if i.IDGT != nil { + predicates = append(predicates, quest.IDGT(*i.IDGT)) } - if i.AgentIdentifierHasSuffix != nil { - predicates = append(predicates, session.AgentIdentifierHasSuffix(*i.AgentIdentifierHasSuffix)) + if i.IDGTE != nil { + predicates = append(predicates, quest.IDGTE(*i.IDGTE)) } - if i.AgentIdentifierIsNil { - predicates = append(predicates, session.AgentIdentifierIsNil()) + if i.IDLT != nil { + predicates = append(predicates, quest.IDLT(*i.IDLT)) } - if i.AgentIdentifierNotNil { - predicates = append(predicates, session.AgentIdentifierNotNil()) + if i.IDLTE != nil { + predicates = append(predicates, quest.IDLTE(*i.IDLTE)) } - if i.AgentIdentifierEqualFold != nil { - predicates = append(predicates, session.AgentIdentifierEqualFold(*i.AgentIdentifierEqualFold)) + if i.CreatedAt != nil { + predicates = append(predicates, quest.CreatedAtEQ(*i.CreatedAt)) } - if i.AgentIdentifierContainsFold != nil { - predicates = append(predicates, session.AgentIdentifierContainsFold(*i.AgentIdentifierContainsFold)) + if i.CreatedAtNEQ != nil { + predicates = append(predicates, quest.CreatedAtNEQ(*i.CreatedAtNEQ)) } - if i.HostIdentifier != nil { - predicates = append(predicates, session.HostIdentifierEQ(*i.HostIdentifier)) + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, quest.CreatedAtIn(i.CreatedAtIn...)) } - if i.HostIdentifierNEQ != nil { - predicates = append(predicates, session.HostIdentifierNEQ(*i.HostIdentifierNEQ)) + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, quest.CreatedAtNotIn(i.CreatedAtNotIn...)) } - if len(i.HostIdentifierIn) > 0 { - predicates = append(predicates, session.HostIdentifierIn(i.HostIdentifierIn...)) + if i.CreatedAtGT != nil { + predicates = append(predicates, quest.CreatedAtGT(*i.CreatedAtGT)) } - if len(i.HostIdentifierNotIn) > 0 { - predicates = append(predicates, session.HostIdentifierNotIn(i.HostIdentifierNotIn...)) + if i.CreatedAtGTE != nil { + predicates = append(predicates, quest.CreatedAtGTE(*i.CreatedAtGTE)) } - if i.HostIdentifierGT != nil { - predicates = append(predicates, session.HostIdentifierGT(*i.HostIdentifierGT)) + if i.CreatedAtLT != nil { + predicates = append(predicates, quest.CreatedAtLT(*i.CreatedAtLT)) } - if i.HostIdentifierGTE != nil { - predicates = append(predicates, session.HostIdentifierGTE(*i.HostIdentifierGTE)) + if i.CreatedAtLTE != nil { + predicates = append(predicates, quest.CreatedAtLTE(*i.CreatedAtLTE)) } - if i.HostIdentifierLT != nil { - predicates = append(predicates, session.HostIdentifierLT(*i.HostIdentifierLT)) + if i.LastModifiedAt != nil { + predicates = append(predicates, quest.LastModifiedAtEQ(*i.LastModifiedAt)) } - if i.HostIdentifierLTE != nil { - predicates = append(predicates, session.HostIdentifierLTE(*i.HostIdentifierLTE)) + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, quest.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) } - if i.HostIdentifierContains != nil { - predicates = append(predicates, session.HostIdentifierContains(*i.HostIdentifierContains)) + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, quest.LastModifiedAtIn(i.LastModifiedAtIn...)) } - if i.HostIdentifierHasPrefix != nil { - predicates = append(predicates, session.HostIdentifierHasPrefix(*i.HostIdentifierHasPrefix)) + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, quest.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) } - if i.HostIdentifierHasSuffix != nil { - predicates = append(predicates, session.HostIdentifierHasSuffix(*i.HostIdentifierHasSuffix)) + if i.LastModifiedAtGT != nil { + predicates = append(predicates, quest.LastModifiedAtGT(*i.LastModifiedAtGT)) } - if i.HostIdentifierIsNil { - predicates = append(predicates, session.HostIdentifierIsNil()) + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, quest.LastModifiedAtGTE(*i.LastModifiedAtGTE)) } - if i.HostIdentifierNotNil { - predicates = append(predicates, session.HostIdentifierNotNil()) + if i.LastModifiedAtLT != nil { + predicates = append(predicates, quest.LastModifiedAtLT(*i.LastModifiedAtLT)) } - if i.HostIdentifierEqualFold != nil { - predicates = append(predicates, session.HostIdentifierEqualFold(*i.HostIdentifierEqualFold)) + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, quest.LastModifiedAtLTE(*i.LastModifiedAtLTE)) } - if i.HostIdentifierContainsFold != nil { - predicates = append(predicates, session.HostIdentifierContainsFold(*i.HostIdentifierContainsFold)) + if i.Name != nil { + predicates = append(predicates, quest.NameEQ(*i.Name)) } - if i.HostPrimaryIP != nil { - predicates = append(predicates, session.HostPrimaryIPEQ(*i.HostPrimaryIP)) + if i.NameNEQ != nil { + predicates = append(predicates, quest.NameNEQ(*i.NameNEQ)) } - if i.HostPrimaryIPNEQ != nil { - predicates = append(predicates, session.HostPrimaryIPNEQ(*i.HostPrimaryIPNEQ)) + if len(i.NameIn) > 0 { + predicates = append(predicates, quest.NameIn(i.NameIn...)) } - if len(i.HostPrimaryIPIn) > 0 { - predicates = append(predicates, session.HostPrimaryIPIn(i.HostPrimaryIPIn...)) + if len(i.NameNotIn) > 0 { + predicates = append(predicates, quest.NameNotIn(i.NameNotIn...)) } - if len(i.HostPrimaryIPNotIn) > 0 { - predicates = append(predicates, session.HostPrimaryIPNotIn(i.HostPrimaryIPNotIn...)) + if i.NameGT != nil { + predicates = append(predicates, quest.NameGT(*i.NameGT)) } - if i.HostPrimaryIPGT != nil { - predicates = append(predicates, session.HostPrimaryIPGT(*i.HostPrimaryIPGT)) + if i.NameGTE != nil { + predicates = append(predicates, quest.NameGTE(*i.NameGTE)) } - if i.HostPrimaryIPGTE != nil { - predicates = append(predicates, session.HostPrimaryIPGTE(*i.HostPrimaryIPGTE)) + if i.NameLT != nil { + predicates = append(predicates, quest.NameLT(*i.NameLT)) } - if i.HostPrimaryIPLT != nil { - predicates = append(predicates, session.HostPrimaryIPLT(*i.HostPrimaryIPLT)) + if i.NameLTE != nil { + predicates = append(predicates, quest.NameLTE(*i.NameLTE)) } - if i.HostPrimaryIPLTE != nil { - predicates = append(predicates, session.HostPrimaryIPLTE(*i.HostPrimaryIPLTE)) + if i.NameContains != nil { + predicates = append(predicates, quest.NameContains(*i.NameContains)) } - if i.HostPrimaryIPContains != nil { - predicates = append(predicates, session.HostPrimaryIPContains(*i.HostPrimaryIPContains)) + if i.NameHasPrefix != nil { + predicates = append(predicates, quest.NameHasPrefix(*i.NameHasPrefix)) } - if i.HostPrimaryIPHasPrefix != nil { - predicates = append(predicates, session.HostPrimaryIPHasPrefix(*i.HostPrimaryIPHasPrefix)) + if i.NameHasSuffix != nil { + predicates = append(predicates, quest.NameHasSuffix(*i.NameHasSuffix)) } - if i.HostPrimaryIPHasSuffix != nil { - predicates = append(predicates, session.HostPrimaryIPHasSuffix(*i.HostPrimaryIPHasSuffix)) + if i.NameEqualFold != nil { + predicates = append(predicates, quest.NameEqualFold(*i.NameEqualFold)) } - if i.HostPrimaryIPIsNil { - predicates = append(predicates, session.HostPrimaryIPIsNil()) + if i.NameContainsFold != nil { + predicates = append(predicates, quest.NameContainsFold(*i.NameContainsFold)) } - if i.HostPrimaryIPNotNil { - predicates = append(predicates, session.HostPrimaryIPNotNil()) + if i.Parameters != nil { + predicates = append(predicates, quest.ParametersEQ(*i.Parameters)) } - if i.HostPrimaryIPEqualFold != nil { - predicates = append(predicates, session.HostPrimaryIPEqualFold(*i.HostPrimaryIPEqualFold)) + if i.ParametersNEQ != nil { + predicates = append(predicates, quest.ParametersNEQ(*i.ParametersNEQ)) } - if i.HostPrimaryIPContainsFold != nil { - predicates = append(predicates, session.HostPrimaryIPContainsFold(*i.HostPrimaryIPContainsFold)) + if len(i.ParametersIn) > 0 { + predicates = append(predicates, quest.ParametersIn(i.ParametersIn...)) } - if i.HostPlatform != nil { - predicates = append(predicates, session.HostPlatformEQ(*i.HostPlatform)) + if len(i.ParametersNotIn) > 0 { + predicates = append(predicates, quest.ParametersNotIn(i.ParametersNotIn...)) } - if i.HostPlatformNEQ != nil { - predicates = append(predicates, session.HostPlatformNEQ(*i.HostPlatformNEQ)) + if i.ParametersGT != nil { + predicates = append(predicates, quest.ParametersGT(*i.ParametersGT)) } - if len(i.HostPlatformIn) > 0 { - predicates = append(predicates, session.HostPlatformIn(i.HostPlatformIn...)) + if i.ParametersGTE != nil { + predicates = append(predicates, quest.ParametersGTE(*i.ParametersGTE)) } - if len(i.HostPlatformNotIn) > 0 { - predicates = append(predicates, session.HostPlatformNotIn(i.HostPlatformNotIn...)) + if i.ParametersLT != nil { + predicates = append(predicates, quest.ParametersLT(*i.ParametersLT)) } - if i.LastSeenAt != nil { - predicates = append(predicates, session.LastSeenAtEQ(*i.LastSeenAt)) + if i.ParametersLTE != nil { + predicates = append(predicates, quest.ParametersLTE(*i.ParametersLTE)) } - if i.LastSeenAtNEQ != nil { - predicates = append(predicates, session.LastSeenAtNEQ(*i.LastSeenAtNEQ)) + if i.ParametersContains != nil { + predicates = append(predicates, quest.ParametersContains(*i.ParametersContains)) } - if len(i.LastSeenAtIn) > 0 { - predicates = append(predicates, session.LastSeenAtIn(i.LastSeenAtIn...)) + if i.ParametersHasPrefix != nil { + predicates = append(predicates, quest.ParametersHasPrefix(*i.ParametersHasPrefix)) } - if len(i.LastSeenAtNotIn) > 0 { - predicates = append(predicates, session.LastSeenAtNotIn(i.LastSeenAtNotIn...)) + if i.ParametersHasSuffix != nil { + predicates = append(predicates, quest.ParametersHasSuffix(*i.ParametersHasSuffix)) } - if i.LastSeenAtGT != nil { - predicates = append(predicates, session.LastSeenAtGT(*i.LastSeenAtGT)) + if i.ParametersIsNil { + predicates = append(predicates, quest.ParametersIsNil()) } - if i.LastSeenAtGTE != nil { - predicates = append(predicates, session.LastSeenAtGTE(*i.LastSeenAtGTE)) + if i.ParametersNotNil { + predicates = append(predicates, quest.ParametersNotNil()) } - if i.LastSeenAtLT != nil { - predicates = append(predicates, session.LastSeenAtLT(*i.LastSeenAtLT)) + if i.ParametersEqualFold != nil { + predicates = append(predicates, quest.ParametersEqualFold(*i.ParametersEqualFold)) } - if i.LastSeenAtLTE != nil { - predicates = append(predicates, session.LastSeenAtLTE(*i.LastSeenAtLTE)) + if i.ParametersContainsFold != nil { + predicates = append(predicates, quest.ParametersContainsFold(*i.ParametersContainsFold)) } - if i.LastSeenAtIsNil { - predicates = append(predicates, session.LastSeenAtIsNil()) + + if i.HasTome != nil { + p := quest.HasTome() + if !*i.HasTome { + p = quest.Not(p) + } + predicates = append(predicates, p) } - if i.LastSeenAtNotNil { - predicates = append(predicates, session.LastSeenAtNotNil()) + if len(i.HasTomeWith) > 0 { + with := make([]predicate.Tome, 0, len(i.HasTomeWith)) + for _, w := range i.HasTomeWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasTomeWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, quest.HasTomeWith(with...)) } - - if i.HasTags != nil { - p := session.HasTags() - if !*i.HasTags { - p = session.Not(p) + if i.HasBundle != nil { + p := quest.HasBundle() + if !*i.HasBundle { + p = quest.Not(p) } predicates = append(predicates, p) } - if len(i.HasTagsWith) > 0 { - with := make([]predicate.Tag, 0, len(i.HasTagsWith)) - for _, w := range i.HasTagsWith { + if len(i.HasBundleWith) > 0 { + with := make([]predicate.File, 0, len(i.HasBundleWith)) + for _, w := range i.HasBundleWith { p, err := w.P() if err != nil { - return nil, fmt.Errorf("%w: field 'HasTagsWith'", err) + return nil, fmt.Errorf("%w: field 'HasBundleWith'", err) } with = append(with, p) } - predicates = append(predicates, session.HasTagsWith(with...)) + predicates = append(predicates, quest.HasBundleWith(with...)) } if i.HasTasks != nil { - p := session.HasTasks() + p := quest.HasTasks() if !*i.HasTasks { - p = session.Not(p) + p = quest.Not(p) } predicates = append(predicates, p) } @@ -1381,15 +1363,33 @@ func (i *SessionWhereInput) P() (predicate.Session, error) { } with = append(with, p) } - predicates = append(predicates, session.HasTasksWith(with...)) + predicates = append(predicates, quest.HasTasksWith(with...)) + } + if i.HasCreator != nil { + p := quest.HasCreator() + if !*i.HasCreator { + p = quest.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasCreatorWith) > 0 { + with := make([]predicate.User, 0, len(i.HasCreatorWith)) + for _, w := range i.HasCreatorWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasCreatorWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, quest.HasCreatorWith(with...)) } switch len(predicates) { case 0: - return nil, ErrEmptySessionWhereInput + return nil, ErrEmptyQuestWhereInput case 1: return predicates[0], nil default: - return session.And(predicates...), nil + return quest.And(predicates...), nil } } @@ -1431,9 +1431,9 @@ type TagWhereInput struct { KindIn []tag.Kind `json:"kindIn,omitempty"` KindNotIn []tag.Kind `json:"kindNotIn,omitempty"` - // "sessions" edge predicates. - HasSessions *bool `json:"hasSessions,omitempty"` - HasSessionsWith []*SessionWhereInput `json:"hasSessionsWith,omitempty"` + // "beacons" edge predicates. + HasBeacons *bool `json:"hasBeacons,omitempty"` + HasBeaconsWith []*BeaconWhereInput `json:"hasBeaconsWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -1583,23 +1583,23 @@ func (i *TagWhereInput) P() (predicate.Tag, error) { predicates = append(predicates, tag.KindNotIn(i.KindNotIn...)) } - if i.HasSessions != nil { - p := tag.HasSessions() - if !*i.HasSessions { + if i.HasBeacons != nil { + p := tag.HasBeacons() + if !*i.HasBeacons { p = tag.Not(p) } predicates = append(predicates, p) } - if len(i.HasSessionsWith) > 0 { - with := make([]predicate.Session, 0, len(i.HasSessionsWith)) - for _, w := range i.HasSessionsWith { + if len(i.HasBeaconsWith) > 0 { + with := make([]predicate.Beacon, 0, len(i.HasBeaconsWith)) + for _, w := range i.HasBeaconsWith { p, err := w.P() if err != nil { - return nil, fmt.Errorf("%w: field 'HasSessionsWith'", err) + return nil, fmt.Errorf("%w: field 'HasBeaconsWith'", err) } with = append(with, p) } - predicates = append(predicates, tag.HasSessionsWith(with...)) + predicates = append(predicates, tag.HasBeaconsWith(with...)) } switch len(predicates) { case 0: @@ -1718,13 +1718,13 @@ type TaskWhereInput struct { ErrorEqualFold *string `json:"errorEqualFold,omitempty"` ErrorContainsFold *string `json:"errorContainsFold,omitempty"` - // "job" edge predicates. - HasJob *bool `json:"hasJob,omitempty"` - HasJobWith []*JobWhereInput `json:"hasJobWith,omitempty"` + // "quest" edge predicates. + HasQuest *bool `json:"hasQuest,omitempty"` + HasQuestWith []*QuestWhereInput `json:"hasQuestWith,omitempty"` - // "session" edge predicates. - HasSession *bool `json:"hasSession,omitempty"` - HasSessionWith []*SessionWhereInput `json:"hasSessionWith,omitempty"` + // "beacon" edge predicates. + HasBeacon *bool `json:"hasBeacon,omitempty"` + HasBeaconWith []*BeaconWhereInput `json:"hasBeaconWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -2051,41 +2051,41 @@ func (i *TaskWhereInput) P() (predicate.Task, error) { predicates = append(predicates, task.ErrorContainsFold(*i.ErrorContainsFold)) } - if i.HasJob != nil { - p := task.HasJob() - if !*i.HasJob { + if i.HasQuest != nil { + p := task.HasQuest() + if !*i.HasQuest { p = task.Not(p) } predicates = append(predicates, p) } - if len(i.HasJobWith) > 0 { - with := make([]predicate.Job, 0, len(i.HasJobWith)) - for _, w := range i.HasJobWith { + if len(i.HasQuestWith) > 0 { + with := make([]predicate.Quest, 0, len(i.HasQuestWith)) + for _, w := range i.HasQuestWith { p, err := w.P() if err != nil { - return nil, fmt.Errorf("%w: field 'HasJobWith'", err) + return nil, fmt.Errorf("%w: field 'HasQuestWith'", err) } with = append(with, p) } - predicates = append(predicates, task.HasJobWith(with...)) + predicates = append(predicates, task.HasQuestWith(with...)) } - if i.HasSession != nil { - p := task.HasSession() - if !*i.HasSession { + if i.HasBeacon != nil { + p := task.HasBeacon() + if !*i.HasBeacon { p = task.Not(p) } predicates = append(predicates, p) } - if len(i.HasSessionWith) > 0 { - with := make([]predicate.Session, 0, len(i.HasSessionWith)) - for _, w := range i.HasSessionWith { + if len(i.HasBeaconWith) > 0 { + with := make([]predicate.Beacon, 0, len(i.HasBeaconWith)) + for _, w := range i.HasBeaconWith { p, err := w.P() if err != nil { - return nil, fmt.Errorf("%w: field 'HasSessionWith'", err) + return nil, fmt.Errorf("%w: field 'HasBeaconWith'", err) } with = append(with, p) } - predicates = append(predicates, task.HasSessionWith(with...)) + predicates = append(predicates, task.HasBeaconWith(with...)) } switch len(predicates) { case 0: diff --git a/tavern/ent/hook/hook.go b/tavern/ent/hook/hook.go index 0ae8311d4..9da956750 100644 --- a/tavern/ent/hook/hook.go +++ b/tavern/ent/hook/hook.go @@ -9,40 +9,40 @@ import ( "github.com/kcarretto/realm/tavern/ent" ) -// The FileFunc type is an adapter to allow the use of ordinary -// function as File mutator. -type FileFunc func(context.Context, *ent.FileMutation) (ent.Value, error) +// The BeaconFunc type is an adapter to allow the use of ordinary +// function as Beacon mutator. +type BeaconFunc func(context.Context, *ent.BeaconMutation) (ent.Value, error) // Mutate calls f(ctx, m). -func (f FileFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.FileMutation); ok { +func (f BeaconFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.BeaconMutation); ok { return f(ctx, mv) } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.FileMutation", m) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BeaconMutation", m) } -// The JobFunc type is an adapter to allow the use of ordinary -// function as Job mutator. -type JobFunc func(context.Context, *ent.JobMutation) (ent.Value, error) +// The FileFunc type is an adapter to allow the use of ordinary +// function as File mutator. +type FileFunc func(context.Context, *ent.FileMutation) (ent.Value, error) // Mutate calls f(ctx, m). -func (f JobFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.JobMutation); ok { +func (f FileFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.FileMutation); ok { return f(ctx, mv) } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.JobMutation", m) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.FileMutation", m) } -// The SessionFunc type is an adapter to allow the use of ordinary -// function as Session mutator. -type SessionFunc func(context.Context, *ent.SessionMutation) (ent.Value, error) +// The QuestFunc type is an adapter to allow the use of ordinary +// function as Quest mutator. +type QuestFunc func(context.Context, *ent.QuestMutation) (ent.Value, error) // Mutate calls f(ctx, m). -func (f SessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.SessionMutation); ok { +func (f QuestFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.QuestMutation); ok { return f(ctx, mv) } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SessionMutation", m) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.QuestMutation", m) } // The TagFunc type is an adapter to allow the use of ordinary diff --git a/tavern/ent/job_create.go b/tavern/ent/job_create.go deleted file mode 100644 index 33f612669..000000000 --- a/tavern/ent/job_create.go +++ /dev/null @@ -1,409 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/task" - "github.com/kcarretto/realm/tavern/ent/tome" - "github.com/kcarretto/realm/tavern/ent/user" -) - -// JobCreate is the builder for creating a Job entity. -type JobCreate struct { - config - mutation *JobMutation - hooks []Hook -} - -// SetCreatedAt sets the "created_at" field. -func (jc *JobCreate) SetCreatedAt(t time.Time) *JobCreate { - jc.mutation.SetCreatedAt(t) - return jc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (jc *JobCreate) SetNillableCreatedAt(t *time.Time) *JobCreate { - if t != nil { - jc.SetCreatedAt(*t) - } - return jc -} - -// SetLastModifiedAt sets the "last_modified_at" field. -func (jc *JobCreate) SetLastModifiedAt(t time.Time) *JobCreate { - jc.mutation.SetLastModifiedAt(t) - return jc -} - -// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. -func (jc *JobCreate) SetNillableLastModifiedAt(t *time.Time) *JobCreate { - if t != nil { - jc.SetLastModifiedAt(*t) - } - return jc -} - -// SetName sets the "name" field. -func (jc *JobCreate) SetName(s string) *JobCreate { - jc.mutation.SetName(s) - return jc -} - -// SetParameters sets the "parameters" field. -func (jc *JobCreate) SetParameters(s string) *JobCreate { - jc.mutation.SetParameters(s) - return jc -} - -// SetNillableParameters sets the "parameters" field if the given value is not nil. -func (jc *JobCreate) SetNillableParameters(s *string) *JobCreate { - if s != nil { - jc.SetParameters(*s) - } - return jc -} - -// SetTomeID sets the "tome" edge to the Tome entity by ID. -func (jc *JobCreate) SetTomeID(id int) *JobCreate { - jc.mutation.SetTomeID(id) - return jc -} - -// SetTome sets the "tome" edge to the Tome entity. -func (jc *JobCreate) SetTome(t *Tome) *JobCreate { - return jc.SetTomeID(t.ID) -} - -// SetBundleID sets the "bundle" edge to the File entity by ID. -func (jc *JobCreate) SetBundleID(id int) *JobCreate { - jc.mutation.SetBundleID(id) - return jc -} - -// SetNillableBundleID sets the "bundle" edge to the File entity by ID if the given value is not nil. -func (jc *JobCreate) SetNillableBundleID(id *int) *JobCreate { - if id != nil { - jc = jc.SetBundleID(*id) - } - return jc -} - -// SetBundle sets the "bundle" edge to the File entity. -func (jc *JobCreate) SetBundle(f *File) *JobCreate { - return jc.SetBundleID(f.ID) -} - -// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. -func (jc *JobCreate) AddTaskIDs(ids ...int) *JobCreate { - jc.mutation.AddTaskIDs(ids...) - return jc -} - -// AddTasks adds the "tasks" edges to the Task entity. -func (jc *JobCreate) AddTasks(t ...*Task) *JobCreate { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return jc.AddTaskIDs(ids...) -} - -// SetCreatorID sets the "creator" edge to the User entity by ID. -func (jc *JobCreate) SetCreatorID(id int) *JobCreate { - jc.mutation.SetCreatorID(id) - return jc -} - -// SetNillableCreatorID sets the "creator" edge to the User entity by ID if the given value is not nil. -func (jc *JobCreate) SetNillableCreatorID(id *int) *JobCreate { - if id != nil { - jc = jc.SetCreatorID(*id) - } - return jc -} - -// SetCreator sets the "creator" edge to the User entity. -func (jc *JobCreate) SetCreator(u *User) *JobCreate { - return jc.SetCreatorID(u.ID) -} - -// Mutation returns the JobMutation object of the builder. -func (jc *JobCreate) Mutation() *JobMutation { - return jc.mutation -} - -// Save creates the Job in the database. -func (jc *JobCreate) Save(ctx context.Context) (*Job, error) { - jc.defaults() - return withHooks[*Job, JobMutation](ctx, jc.sqlSave, jc.mutation, jc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (jc *JobCreate) SaveX(ctx context.Context) *Job { - v, err := jc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (jc *JobCreate) Exec(ctx context.Context) error { - _, err := jc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (jc *JobCreate) ExecX(ctx context.Context) { - if err := jc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (jc *JobCreate) defaults() { - if _, ok := jc.mutation.CreatedAt(); !ok { - v := job.DefaultCreatedAt() - jc.mutation.SetCreatedAt(v) - } - if _, ok := jc.mutation.LastModifiedAt(); !ok { - v := job.DefaultLastModifiedAt() - jc.mutation.SetLastModifiedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (jc *JobCreate) check() error { - if _, ok := jc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Job.created_at"`)} - } - if _, ok := jc.mutation.LastModifiedAt(); !ok { - return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Job.last_modified_at"`)} - } - if _, ok := jc.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Job.name"`)} - } - if v, ok := jc.mutation.Name(); ok { - if err := job.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Job.name": %w`, err)} - } - } - if _, ok := jc.mutation.TomeID(); !ok { - return &ValidationError{Name: "tome", err: errors.New(`ent: missing required edge "Job.tome"`)} - } - return nil -} - -func (jc *JobCreate) sqlSave(ctx context.Context) (*Job, error) { - if err := jc.check(); err != nil { - return nil, err - } - _node, _spec := jc.createSpec() - if err := sqlgraph.CreateNode(ctx, jc.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) - jc.mutation.id = &_node.ID - jc.mutation.done = true - return _node, nil -} - -func (jc *JobCreate) createSpec() (*Job, *sqlgraph.CreateSpec) { - var ( - _node = &Job{config: jc.config} - _spec = sqlgraph.NewCreateSpec(job.Table, sqlgraph.NewFieldSpec(job.FieldID, field.TypeInt)) - ) - if value, ok := jc.mutation.CreatedAt(); ok { - _spec.SetField(job.FieldCreatedAt, field.TypeTime, value) - _node.CreatedAt = value - } - if value, ok := jc.mutation.LastModifiedAt(); ok { - _spec.SetField(job.FieldLastModifiedAt, field.TypeTime, value) - _node.LastModifiedAt = value - } - if value, ok := jc.mutation.Name(); ok { - _spec.SetField(job.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := jc.mutation.Parameters(); ok { - _spec.SetField(job.FieldParameters, field.TypeString, value) - _node.Parameters = value - } - if nodes := jc.mutation.TomeIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: job.TomeTable, - Columns: []string{job.TomeColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tome.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.job_tome = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := jc.mutation.BundleIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: job.BundleTable, - Columns: []string{job.BundleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: file.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.job_bundle = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := jc.mutation.TasksIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: job.TasksTable, - Columns: []string{job.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := jc.mutation.CreatorIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: job.CreatorTable, - Columns: []string{job.CreatorColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.job_creator = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// JobCreateBulk is the builder for creating many Job entities in bulk. -type JobCreateBulk struct { - config - builders []*JobCreate -} - -// Save creates the Job entities in the database. -func (jcb *JobCreateBulk) Save(ctx context.Context) ([]*Job, error) { - specs := make([]*sqlgraph.CreateSpec, len(jcb.builders)) - nodes := make([]*Job, len(jcb.builders)) - mutators := make([]Mutator, len(jcb.builders)) - for i := range jcb.builders { - func(i int, root context.Context) { - builder := jcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*JobMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, jcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, jcb.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, jcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (jcb *JobCreateBulk) SaveX(ctx context.Context) []*Job { - v, err := jcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (jcb *JobCreateBulk) Exec(ctx context.Context) error { - _, err := jcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (jcb *JobCreateBulk) ExecX(ctx context.Context) { - if err := jcb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/tavern/ent/job_delete.go b/tavern/ent/job_delete.go deleted file mode 100644 index ff2eb5ea6..000000000 --- a/tavern/ent/job_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" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/predicate" -) - -// JobDelete is the builder for deleting a Job entity. -type JobDelete struct { - config - hooks []Hook - mutation *JobMutation -} - -// Where appends a list predicates to the JobDelete builder. -func (jd *JobDelete) Where(ps ...predicate.Job) *JobDelete { - jd.mutation.Where(ps...) - return jd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (jd *JobDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, JobMutation](ctx, jd.sqlExec, jd.mutation, jd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (jd *JobDelete) ExecX(ctx context.Context) int { - n, err := jd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (jd *JobDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(job.Table, sqlgraph.NewFieldSpec(job.FieldID, field.TypeInt)) - if ps := jd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, jd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - jd.mutation.done = true - return affected, err -} - -// JobDeleteOne is the builder for deleting a single Job entity. -type JobDeleteOne struct { - jd *JobDelete -} - -// Where appends a list predicates to the JobDelete builder. -func (jdo *JobDeleteOne) Where(ps ...predicate.Job) *JobDeleteOne { - jdo.jd.mutation.Where(ps...) - return jdo -} - -// Exec executes the deletion query. -func (jdo *JobDeleteOne) Exec(ctx context.Context) error { - n, err := jdo.jd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{job.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (jdo *JobDeleteOne) ExecX(ctx context.Context) { - if err := jdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/tavern/ent/job_query.go b/tavern/ent/job_query.go deleted file mode 100644 index a972941cb..000000000 --- a/tavern/ent/job_query.go +++ /dev/null @@ -1,874 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/task" - "github.com/kcarretto/realm/tavern/ent/tome" - "github.com/kcarretto/realm/tavern/ent/user" -) - -// JobQuery is the builder for querying Job entities. -type JobQuery struct { - config - ctx *QueryContext - order []OrderFunc - inters []Interceptor - predicates []predicate.Job - withTome *TomeQuery - withBundle *FileQuery - withTasks *TaskQuery - withCreator *UserQuery - withFKs bool - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Job) error - withNamedTasks map[string]*TaskQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the JobQuery builder. -func (jq *JobQuery) Where(ps ...predicate.Job) *JobQuery { - jq.predicates = append(jq.predicates, ps...) - return jq -} - -// Limit the number of records to be returned by this query. -func (jq *JobQuery) Limit(limit int) *JobQuery { - jq.ctx.Limit = &limit - return jq -} - -// Offset to start from. -func (jq *JobQuery) Offset(offset int) *JobQuery { - jq.ctx.Offset = &offset - return jq -} - -// 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 (jq *JobQuery) Unique(unique bool) *JobQuery { - jq.ctx.Unique = &unique - return jq -} - -// Order specifies how the records should be ordered. -func (jq *JobQuery) Order(o ...OrderFunc) *JobQuery { - jq.order = append(jq.order, o...) - return jq -} - -// QueryTome chains the current query on the "tome" edge. -func (jq *JobQuery) QueryTome() *TomeQuery { - query := (&TomeClient{config: jq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := jq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := jq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, selector), - sqlgraph.To(tome.Table, tome.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, job.TomeTable, job.TomeColumn), - ) - fromU = sqlgraph.SetNeighbors(jq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryBundle chains the current query on the "bundle" edge. -func (jq *JobQuery) QueryBundle() *FileQuery { - query := (&FileClient{config: jq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := jq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := jq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, selector), - sqlgraph.To(file.Table, file.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, job.BundleTable, job.BundleColumn), - ) - fromU = sqlgraph.SetNeighbors(jq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryTasks chains the current query on the "tasks" edge. -func (jq *JobQuery) QueryTasks() *TaskQuery { - query := (&TaskClient{config: jq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := jq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := jq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, selector), - sqlgraph.To(task.Table, task.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, job.TasksTable, job.TasksColumn), - ) - fromU = sqlgraph.SetNeighbors(jq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryCreator chains the current query on the "creator" edge. -func (jq *JobQuery) QueryCreator() *UserQuery { - query := (&UserClient{config: jq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := jq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := jq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(job.Table, job.FieldID, selector), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, job.CreatorTable, job.CreatorColumn), - ) - fromU = sqlgraph.SetNeighbors(jq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Job entity from the query. -// Returns a *NotFoundError when no Job was found. -func (jq *JobQuery) First(ctx context.Context) (*Job, error) { - nodes, err := jq.Limit(1).All(setContextOp(ctx, jq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{job.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (jq *JobQuery) FirstX(ctx context.Context) *Job { - node, err := jq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Job ID from the query. -// Returns a *NotFoundError when no Job ID was found. -func (jq *JobQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = jq.Limit(1).IDs(setContextOp(ctx, jq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{job.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (jq *JobQuery) FirstIDX(ctx context.Context) int { - id, err := jq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Job entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Job entity is found. -// Returns a *NotFoundError when no Job entities are found. -func (jq *JobQuery) Only(ctx context.Context) (*Job, error) { - nodes, err := jq.Limit(2).All(setContextOp(ctx, jq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{job.Label} - default: - return nil, &NotSingularError{job.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (jq *JobQuery) OnlyX(ctx context.Context) *Job { - node, err := jq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Job ID in the query. -// Returns a *NotSingularError when more than one Job ID is found. -// Returns a *NotFoundError when no entities are found. -func (jq *JobQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = jq.Limit(2).IDs(setContextOp(ctx, jq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{job.Label} - default: - err = &NotSingularError{job.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (jq *JobQuery) OnlyIDX(ctx context.Context) int { - id, err := jq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Jobs. -func (jq *JobQuery) All(ctx context.Context) ([]*Job, error) { - ctx = setContextOp(ctx, jq.ctx, "All") - if err := jq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Job, *JobQuery]() - return withInterceptors[[]*Job](ctx, jq, qr, jq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (jq *JobQuery) AllX(ctx context.Context) []*Job { - nodes, err := jq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Job IDs. -func (jq *JobQuery) IDs(ctx context.Context) (ids []int, err error) { - if jq.ctx.Unique == nil && jq.path != nil { - jq.Unique(true) - } - ctx = setContextOp(ctx, jq.ctx, "IDs") - if err = jq.Select(job.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (jq *JobQuery) IDsX(ctx context.Context) []int { - ids, err := jq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (jq *JobQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, jq.ctx, "Count") - if err := jq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, jq, querierCount[*JobQuery](), jq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (jq *JobQuery) CountX(ctx context.Context) int { - count, err := jq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (jq *JobQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, jq.ctx, "Exist") - switch _, err := jq.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 (jq *JobQuery) ExistX(ctx context.Context) bool { - exist, err := jq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the JobQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (jq *JobQuery) Clone() *JobQuery { - if jq == nil { - return nil - } - return &JobQuery{ - config: jq.config, - ctx: jq.ctx.Clone(), - order: append([]OrderFunc{}, jq.order...), - inters: append([]Interceptor{}, jq.inters...), - predicates: append([]predicate.Job{}, jq.predicates...), - withTome: jq.withTome.Clone(), - withBundle: jq.withBundle.Clone(), - withTasks: jq.withTasks.Clone(), - withCreator: jq.withCreator.Clone(), - // clone intermediate query. - sql: jq.sql.Clone(), - path: jq.path, - } -} - -// WithTome tells the query-builder to eager-load the nodes that are connected to -// the "tome" edge. The optional arguments are used to configure the query builder of the edge. -func (jq *JobQuery) WithTome(opts ...func(*TomeQuery)) *JobQuery { - query := (&TomeClient{config: jq.config}).Query() - for _, opt := range opts { - opt(query) - } - jq.withTome = query - return jq -} - -// WithBundle tells the query-builder to eager-load the nodes that are connected to -// the "bundle" edge. The optional arguments are used to configure the query builder of the edge. -func (jq *JobQuery) WithBundle(opts ...func(*FileQuery)) *JobQuery { - query := (&FileClient{config: jq.config}).Query() - for _, opt := range opts { - opt(query) - } - jq.withBundle = query - return jq -} - -// WithTasks tells the query-builder to eager-load the nodes that are connected to -// the "tasks" edge. The optional arguments are used to configure the query builder of the edge. -func (jq *JobQuery) WithTasks(opts ...func(*TaskQuery)) *JobQuery { - query := (&TaskClient{config: jq.config}).Query() - for _, opt := range opts { - opt(query) - } - jq.withTasks = query - return jq -} - -// WithCreator tells the query-builder to eager-load the nodes that are connected to -// the "creator" edge. The optional arguments are used to configure the query builder of the edge. -func (jq *JobQuery) WithCreator(opts ...func(*UserQuery)) *JobQuery { - query := (&UserClient{config: jq.config}).Query() - for _, opt := range opts { - opt(query) - } - jq.withCreator = query - return jq -} - -// 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.Job.Query(). -// GroupBy(job.FieldCreatedAt). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (jq *JobQuery) GroupBy(field string, fields ...string) *JobGroupBy { - jq.ctx.Fields = append([]string{field}, fields...) - grbuild := &JobGroupBy{build: jq} - grbuild.flds = &jq.ctx.Fields - grbuild.label = job.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.Job.Query(). -// Select(job.FieldCreatedAt). -// Scan(ctx, &v) -func (jq *JobQuery) Select(fields ...string) *JobSelect { - jq.ctx.Fields = append(jq.ctx.Fields, fields...) - sbuild := &JobSelect{JobQuery: jq} - sbuild.label = job.Label - sbuild.flds, sbuild.scan = &jq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a JobSelect configured with the given aggregations. -func (jq *JobQuery) Aggregate(fns ...AggregateFunc) *JobSelect { - return jq.Select().Aggregate(fns...) -} - -func (jq *JobQuery) prepareQuery(ctx context.Context) error { - for _, inter := range jq.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, jq); err != nil { - return err - } - } - } - for _, f := range jq.ctx.Fields { - if !job.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if jq.path != nil { - prev, err := jq.path(ctx) - if err != nil { - return err - } - jq.sql = prev - } - return nil -} - -func (jq *JobQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Job, error) { - var ( - nodes = []*Job{} - withFKs = jq.withFKs - _spec = jq.querySpec() - loadedTypes = [4]bool{ - jq.withTome != nil, - jq.withBundle != nil, - jq.withTasks != nil, - jq.withCreator != nil, - } - ) - if jq.withTome != nil || jq.withBundle != nil || jq.withCreator != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, job.ForeignKeys...) - } - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Job).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Job{config: jq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(jq.modifiers) > 0 { - _spec.Modifiers = jq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, jq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := jq.withTome; query != nil { - if err := jq.loadTome(ctx, query, nodes, nil, - func(n *Job, e *Tome) { n.Edges.Tome = e }); err != nil { - return nil, err - } - } - if query := jq.withBundle; query != nil { - if err := jq.loadBundle(ctx, query, nodes, nil, - func(n *Job, e *File) { n.Edges.Bundle = e }); err != nil { - return nil, err - } - } - if query := jq.withTasks; query != nil { - if err := jq.loadTasks(ctx, query, nodes, - func(n *Job) { n.Edges.Tasks = []*Task{} }, - func(n *Job, e *Task) { n.Edges.Tasks = append(n.Edges.Tasks, e) }); err != nil { - return nil, err - } - } - if query := jq.withCreator; query != nil { - if err := jq.loadCreator(ctx, query, nodes, nil, - func(n *Job, e *User) { n.Edges.Creator = e }); err != nil { - return nil, err - } - } - for name, query := range jq.withNamedTasks { - if err := jq.loadTasks(ctx, query, nodes, - func(n *Job) { n.appendNamedTasks(name) }, - func(n *Job, e *Task) { n.appendNamedTasks(name, e) }); err != nil { - return nil, err - } - } - for i := range jq.loadTotal { - if err := jq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (jq *JobQuery) loadTome(ctx context.Context, query *TomeQuery, nodes []*Job, init func(*Job), assign func(*Job, *Tome)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Job) - for i := range nodes { - if nodes[i].job_tome == nil { - continue - } - fk := *nodes[i].job_tome - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(tome.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 "job_tome" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (jq *JobQuery) loadBundle(ctx context.Context, query *FileQuery, nodes []*Job, init func(*Job), assign func(*Job, *File)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Job) - for i := range nodes { - if nodes[i].job_bundle == nil { - continue - } - fk := *nodes[i].job_bundle - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(file.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 "job_bundle" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (jq *JobQuery) loadTasks(ctx context.Context, query *TaskQuery, nodes []*Job, init func(*Job), assign func(*Job, *Task)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Job) - 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.Task(func(s *sql.Selector) { - s.Where(sql.InValues(job.TasksColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.job_tasks - if fk == nil { - return fmt.Errorf(`foreign-key "job_tasks" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return fmt.Errorf(`unexpected foreign-key "job_tasks" returned %v for node %v`, *fk, n.ID) - } - assign(node, n) - } - return nil -} -func (jq *JobQuery) loadCreator(ctx context.Context, query *UserQuery, nodes []*Job, init func(*Job), assign func(*Job, *User)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Job) - for i := range nodes { - if nodes[i].job_creator == nil { - continue - } - fk := *nodes[i].job_creator - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(user.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 "job_creator" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} - -func (jq *JobQuery) sqlCount(ctx context.Context) (int, error) { - _spec := jq.querySpec() - if len(jq.modifiers) > 0 { - _spec.Modifiers = jq.modifiers - } - _spec.Node.Columns = jq.ctx.Fields - if len(jq.ctx.Fields) > 0 { - _spec.Unique = jq.ctx.Unique != nil && *jq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, jq.driver, _spec) -} - -func (jq *JobQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(job.Table, job.Columns, sqlgraph.NewFieldSpec(job.FieldID, field.TypeInt)) - _spec.From = jq.sql - if unique := jq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if jq.path != nil { - _spec.Unique = true - } - if fields := jq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, job.FieldID) - for i := range fields { - if fields[i] != job.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := jq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := jq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := jq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := jq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (jq *JobQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(jq.driver.Dialect()) - t1 := builder.Table(job.Table) - columns := jq.ctx.Fields - if len(columns) == 0 { - columns = job.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if jq.sql != nil { - selector = jq.sql - selector.Select(selector.Columns(columns...)...) - } - if jq.ctx.Unique != nil && *jq.ctx.Unique { - selector.Distinct() - } - for _, p := range jq.predicates { - p(selector) - } - for _, p := range jq.order { - p(selector) - } - if offset := jq.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 := jq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedTasks tells the query-builder to eager-load the nodes that are connected to the "tasks" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (jq *JobQuery) WithNamedTasks(name string, opts ...func(*TaskQuery)) *JobQuery { - query := (&TaskClient{config: jq.config}).Query() - for _, opt := range opts { - opt(query) - } - if jq.withNamedTasks == nil { - jq.withNamedTasks = make(map[string]*TaskQuery) - } - jq.withNamedTasks[name] = query - return jq -} - -// JobGroupBy is the group-by builder for Job entities. -type JobGroupBy struct { - selector - build *JobQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (jgb *JobGroupBy) Aggregate(fns ...AggregateFunc) *JobGroupBy { - jgb.fns = append(jgb.fns, fns...) - return jgb -} - -// Scan applies the selector query and scans the result into the given value. -func (jgb *JobGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, jgb.build.ctx, "GroupBy") - if err := jgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*JobQuery, *JobGroupBy](ctx, jgb.build, jgb, jgb.build.inters, v) -} - -func (jgb *JobGroupBy) sqlScan(ctx context.Context, root *JobQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(jgb.fns)) - for _, fn := range jgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*jgb.flds)+len(jgb.fns)) - for _, f := range *jgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*jgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := jgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// JobSelect is the builder for selecting fields of Job entities. -type JobSelect struct { - *JobQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (js *JobSelect) Aggregate(fns ...AggregateFunc) *JobSelect { - js.fns = append(js.fns, fns...) - return js -} - -// Scan applies the selector query and scans the result into the given value. -func (js *JobSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, js.ctx, "Select") - if err := js.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*JobQuery, *JobSelect](ctx, js.JobQuery, js, js.inters, v) -} - -func (js *JobSelect) sqlScan(ctx context.Context, root *JobQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(js.fns)) - for _, fn := range js.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*js.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 := js.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/tavern/ent/migrate/schema.go b/tavern/ent/migrate/schema.go index f245d34f0..ca6c3de74 100644 --- a/tavern/ent/migrate/schema.go +++ b/tavern/ent/migrate/schema.go @@ -8,6 +8,25 @@ import ( ) var ( + // BeaconsColumns holds the columns for the "beacons" table. + BeaconsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "name", Type: field.TypeString, Unique: true}, + {Name: "principal", Type: field.TypeString, Nullable: true}, + {Name: "hostname", Type: field.TypeString, Nullable: true}, + {Name: "identifier", Type: field.TypeString, Unique: true}, + {Name: "agent_identifier", Type: field.TypeString, Nullable: true}, + {Name: "host_identifier", Type: field.TypeString, Nullable: true}, + {Name: "host_primary_ip", Type: field.TypeString, Nullable: true}, + {Name: "host_platform", Type: field.TypeEnum, Enums: []string{"Windows", "Linux", "MacOS", "BSD", "Unknown"}, Default: "Unknown"}, + {Name: "last_seen_at", Type: field.TypeTime, Nullable: true}, + } + // BeaconsTable holds the schema information for the "beacons" table. + BeaconsTable = &schema.Table{ + Name: "beacons", + Columns: BeaconsColumns, + PrimaryKey: []*schema.Column{BeaconsColumns[0]}, + } // FilesColumns holds the columns for the "files" table. FilesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -33,62 +52,43 @@ var ( }, }, } - // JobsColumns holds the columns for the "jobs" table. - JobsColumns = []*schema.Column{ + // QuestsColumns holds the columns for the "quests" table. + QuestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "last_modified_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "parameters", Type: field.TypeString, Nullable: true}, - {Name: "job_tome", Type: field.TypeInt}, - {Name: "job_bundle", Type: field.TypeInt, Nullable: true}, - {Name: "job_creator", Type: field.TypeInt, Nullable: true}, - } - // JobsTable holds the schema information for the "jobs" table. - JobsTable = &schema.Table{ - Name: "jobs", - Columns: JobsColumns, - PrimaryKey: []*schema.Column{JobsColumns[0]}, + {Name: "quest_tome", Type: field.TypeInt}, + {Name: "quest_bundle", Type: field.TypeInt, Nullable: true}, + {Name: "quest_creator", Type: field.TypeInt, Nullable: true}, + } + // QuestsTable holds the schema information for the "quests" table. + QuestsTable = &schema.Table{ + Name: "quests", + Columns: QuestsColumns, + PrimaryKey: []*schema.Column{QuestsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "jobs_tomes_tome", - Columns: []*schema.Column{JobsColumns[5]}, + Symbol: "quests_tomes_tome", + Columns: []*schema.Column{QuestsColumns[5]}, RefColumns: []*schema.Column{TomesColumns[0]}, OnDelete: schema.NoAction, }, { - Symbol: "jobs_files_bundle", - Columns: []*schema.Column{JobsColumns[6]}, + Symbol: "quests_files_bundle", + Columns: []*schema.Column{QuestsColumns[6]}, RefColumns: []*schema.Column{FilesColumns[0]}, OnDelete: schema.SetNull, }, { - Symbol: "jobs_users_creator", - Columns: []*schema.Column{JobsColumns[7]}, + Symbol: "quests_users_creator", + Columns: []*schema.Column{QuestsColumns[7]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } - // SessionsColumns holds the columns for the "sessions" table. - SessionsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "name", Type: field.TypeString, Unique: true}, - {Name: "principal", Type: field.TypeString, Nullable: true}, - {Name: "hostname", Type: field.TypeString, Nullable: true}, - {Name: "identifier", Type: field.TypeString, Unique: true}, - {Name: "agent_identifier", Type: field.TypeString, Nullable: true}, - {Name: "host_identifier", Type: field.TypeString, Nullable: true}, - {Name: "host_primary_ip", Type: field.TypeString, Nullable: true}, - {Name: "host_platform", Type: field.TypeEnum, Enums: []string{"Windows", "Linux", "MacOS", "BSD", "Unknown"}, Default: "Unknown"}, - {Name: "last_seen_at", Type: field.TypeTime, Nullable: true}, - } - // SessionsTable holds the schema information for the "sessions" table. - SessionsTable = &schema.Table{ - Name: "sessions", - Columns: SessionsColumns, - PrimaryKey: []*schema.Column{SessionsColumns[0]}, - } // TagsColumns holds the columns for the "tags" table. TagsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -111,8 +111,8 @@ var ( {Name: "exec_finished_at", Type: field.TypeTime, Nullable: true}, {Name: "output", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "error", Type: field.TypeString, Nullable: true}, - {Name: "job_tasks", Type: field.TypeInt}, - {Name: "task_session", Type: field.TypeInt}, + {Name: "quest_tasks", Type: field.TypeInt}, + {Name: "task_beacon", Type: field.TypeInt}, } // TasksTable holds the schema information for the "tasks" table. TasksTable = &schema.Table{ @@ -121,15 +121,15 @@ var ( PrimaryKey: []*schema.Column{TasksColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "tasks_jobs_tasks", + Symbol: "tasks_quests_tasks", Columns: []*schema.Column{TasksColumns[8]}, - RefColumns: []*schema.Column{JobsColumns[0]}, + RefColumns: []*schema.Column{QuestsColumns[0]}, OnDelete: schema.NoAction, }, { - Symbol: "tasks_sessions_session", + Symbol: "tasks_beacons_beacon", Columns: []*schema.Column{TasksColumns[9]}, - RefColumns: []*schema.Column{SessionsColumns[0]}, + RefColumns: []*schema.Column{BeaconsColumns[0]}, OnDelete: schema.NoAction, }, }, @@ -167,26 +167,26 @@ var ( Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, } - // SessionTagsColumns holds the columns for the "session_tags" table. - SessionTagsColumns = []*schema.Column{ - {Name: "session_id", Type: field.TypeInt}, + // BeaconTagsColumns holds the columns for the "beacon_tags" table. + BeaconTagsColumns = []*schema.Column{ + {Name: "beacon_id", Type: field.TypeInt}, {Name: "tag_id", Type: field.TypeInt}, } - // SessionTagsTable holds the schema information for the "session_tags" table. - SessionTagsTable = &schema.Table{ - Name: "session_tags", - Columns: SessionTagsColumns, - PrimaryKey: []*schema.Column{SessionTagsColumns[0], SessionTagsColumns[1]}, + // BeaconTagsTable holds the schema information for the "beacon_tags" table. + BeaconTagsTable = &schema.Table{ + Name: "beacon_tags", + Columns: BeaconTagsColumns, + PrimaryKey: []*schema.Column{BeaconTagsColumns[0], BeaconTagsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "session_tags_session_id", - Columns: []*schema.Column{SessionTagsColumns[0]}, - RefColumns: []*schema.Column{SessionsColumns[0]}, + Symbol: "beacon_tags_beacon_id", + Columns: []*schema.Column{BeaconTagsColumns[0]}, + RefColumns: []*schema.Column{BeaconsColumns[0]}, OnDelete: schema.Cascade, }, { - Symbol: "session_tags_tag_id", - Columns: []*schema.Column{SessionTagsColumns[1]}, + Symbol: "beacon_tags_tag_id", + Columns: []*schema.Column{BeaconTagsColumns[1]}, RefColumns: []*schema.Column{TagsColumns[0]}, OnDelete: schema.Cascade, }, @@ -194,24 +194,24 @@ var ( } // Tables holds all the tables in the schema. Tables = []*schema.Table{ + BeaconsTable, FilesTable, - JobsTable, - SessionsTable, + QuestsTable, TagsTable, TasksTable, TomesTable, UsersTable, - SessionTagsTable, + BeaconTagsTable, } ) func init() { FilesTable.ForeignKeys[0].RefTable = TomesTable - JobsTable.ForeignKeys[0].RefTable = TomesTable - JobsTable.ForeignKeys[1].RefTable = FilesTable - JobsTable.ForeignKeys[2].RefTable = UsersTable - TasksTable.ForeignKeys[0].RefTable = JobsTable - TasksTable.ForeignKeys[1].RefTable = SessionsTable - SessionTagsTable.ForeignKeys[0].RefTable = SessionsTable - SessionTagsTable.ForeignKeys[1].RefTable = TagsTable + QuestsTable.ForeignKeys[0].RefTable = TomesTable + QuestsTable.ForeignKeys[1].RefTable = FilesTable + QuestsTable.ForeignKeys[2].RefTable = UsersTable + TasksTable.ForeignKeys[0].RefTable = QuestsTable + TasksTable.ForeignKeys[1].RefTable = BeaconsTable + BeaconTagsTable.ForeignKeys[0].RefTable = BeaconsTable + BeaconTagsTable.ForeignKeys[1].RefTable = TagsTable } diff --git a/tavern/ent/mutation.go b/tavern/ent/mutation.go index 7261f7a54..6b89c8eb4 100644 --- a/tavern/ent/mutation.go +++ b/tavern/ent/mutation.go @@ -11,10 +11,10 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" @@ -30,45 +30,53 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. - TypeFile = "File" - TypeJob = "Job" - TypeSession = "Session" - TypeTag = "Tag" - TypeTask = "Task" - TypeTome = "Tome" - TypeUser = "User" + TypeBeacon = "Beacon" + TypeFile = "File" + TypeQuest = "Quest" + TypeTag = "Tag" + TypeTask = "Task" + TypeTome = "Tome" + TypeUser = "User" ) -// FileMutation represents an operation that mutates the File nodes in the graph. -type FileMutation struct { +// BeaconMutation represents an operation that mutates the Beacon nodes in the graph. +type BeaconMutation struct { config op Op typ string id *int - created_at *time.Time - last_modified_at *time.Time name *string - size *int - addsize *int - hash *string - content *[]byte + principal *string + hostname *string + identifier *string + agent_identifier *string + host_identifier *string + host_primary_ip *string + host_platform *beacon.HostPlatform + last_seen_at *time.Time clearedFields map[string]struct{} + tags map[int]struct{} + removedtags map[int]struct{} + clearedtags bool + tasks map[int]struct{} + removedtasks map[int]struct{} + clearedtasks bool done bool - oldValue func(context.Context) (*File, error) - predicates []predicate.File + oldValue func(context.Context) (*Beacon, error) + predicates []predicate.Beacon } -var _ ent.Mutation = (*FileMutation)(nil) +var _ ent.Mutation = (*BeaconMutation)(nil) -// fileOption allows management of the mutation configuration using functional options. -type fileOption func(*FileMutation) +// beaconOption allows management of the mutation configuration using functional options. +type beaconOption func(*BeaconMutation) -// newFileMutation creates new mutation for the File entity. -func newFileMutation(c config, op Op, opts ...fileOption) *FileMutation { - m := &FileMutation{ +// newBeaconMutation creates new mutation for the Beacon entity. +func newBeaconMutation(c config, op Op, opts ...beaconOption) *BeaconMutation { + m := &BeaconMutation{ config: c, op: op, - typ: TypeFile, + typ: TypeBeacon, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -77,20 +85,20 @@ func newFileMutation(c config, op Op, opts ...fileOption) *FileMutation { return m } -// withFileID sets the ID field of the mutation. -func withFileID(id int) fileOption { - return func(m *FileMutation) { +// withBeaconID sets the ID field of the mutation. +func withBeaconID(id int) beaconOption { + return func(m *BeaconMutation) { var ( err error once sync.Once - value *File + value *Beacon ) - m.oldValue = func(ctx context.Context) (*File, error) { + m.oldValue = func(ctx context.Context) (*Beacon, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().File.Get(ctx, id) + value, err = m.Client().Beacon.Get(ctx, id) } }) return value, err @@ -99,10 +107,10 @@ func withFileID(id int) fileOption { } } -// withFile sets the old File of the mutation. -func withFile(node *File) fileOption { - return func(m *FileMutation) { - m.oldValue = func(context.Context) (*File, error) { +// withBeacon sets the old Beacon of the mutation. +func withBeacon(node *Beacon) beaconOption { + return func(m *BeaconMutation) { + m.oldValue = func(context.Context) (*Beacon, error) { return node, nil } m.id = &node.ID @@ -111,7 +119,7 @@ func withFile(node *File) fileOption { // 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 FileMutation) Client() *Client { +func (m BeaconMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -119,7 +127,7 @@ func (m FileMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m FileMutation) Tx() (*Tx, error) { +func (m BeaconMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -130,7 +138,7 @@ func (m FileMutation) 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 *FileMutation) ID() (id int, exists bool) { +func (m *BeaconMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -141,7 +149,7 @@ func (m *FileMutation) 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 *FileMutation) IDs(ctx context.Context) ([]int, error) { +func (m *BeaconMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -150,300 +158,583 @@ func (m *FileMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().File.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Beacon.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 *FileMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetName sets the "name" field. +func (m *BeaconMutation) SetName(s string) { + m.name = &s } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *FileMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// Name returns the value of the "name" field in the mutation. +func (m *BeaconMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the File entity. -// If the File object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Beacon entity. +// If the Beacon 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 *FileMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *BeaconMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldName 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") + return v, errors.New("OldName 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 v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.Name, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *FileMutation) ResetCreatedAt() { - m.created_at = nil +// ResetName resets all changes to the "name" field. +func (m *BeaconMutation) ResetName() { + m.name = nil } -// SetLastModifiedAt sets the "last_modified_at" field. -func (m *FileMutation) SetLastModifiedAt(t time.Time) { - m.last_modified_at = &t +// SetPrincipal sets the "principal" field. +func (m *BeaconMutation) SetPrincipal(s string) { + m.principal = &s } -// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. -func (m *FileMutation) LastModifiedAt() (r time.Time, exists bool) { - v := m.last_modified_at +// Principal returns the value of the "principal" field in the mutation. +func (m *BeaconMutation) Principal() (r string, exists bool) { + v := m.principal if v == nil { return } return *v, true } -// OldLastModifiedAt returns the old "last_modified_at" field's value of the File entity. -// If the File object wasn't provided to the builder, the object is fetched from the database. +// OldPrincipal returns the old "principal" field's value of the Beacon entity. +// If the Beacon 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 *FileMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { +func (m *BeaconMutation) OldPrincipal(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") + return v, errors.New("OldPrincipal 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") + return v, errors.New("OldPrincipal 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 v, fmt.Errorf("querying old value for OldPrincipal: %w", err) } - return oldValue.LastModifiedAt, nil + return oldValue.Principal, nil } -// ResetLastModifiedAt resets all changes to the "last_modified_at" field. -func (m *FileMutation) ResetLastModifiedAt() { - m.last_modified_at = nil +// ClearPrincipal clears the value of the "principal" field. +func (m *BeaconMutation) ClearPrincipal() { + m.principal = nil + m.clearedFields[beacon.FieldPrincipal] = struct{}{} } -// SetName sets the "name" field. -func (m *FileMutation) SetName(s string) { - m.name = &s +// PrincipalCleared returns if the "principal" field was cleared in this mutation. +func (m *BeaconMutation) PrincipalCleared() bool { + _, ok := m.clearedFields[beacon.FieldPrincipal] + return ok } -// Name returns the value of the "name" field in the mutation. -func (m *FileMutation) Name() (r string, exists bool) { - v := m.name +// ResetPrincipal resets all changes to the "principal" field. +func (m *BeaconMutation) ResetPrincipal() { + m.principal = nil + delete(m.clearedFields, beacon.FieldPrincipal) +} + +// SetHostname sets the "hostname" field. +func (m *BeaconMutation) SetHostname(s string) { + m.hostname = &s +} + +// Hostname returns the value of the "hostname" field in the mutation. +func (m *BeaconMutation) Hostname() (r string, exists bool) { + v := m.hostname if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the File entity. -// If the File object wasn't provided to the builder, the object is fetched from the database. +// OldHostname returns the old "hostname" field's value of the Beacon entity. +// If the Beacon 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 *FileMutation) OldName(ctx context.Context) (v string, err error) { +func (m *BeaconMutation) OldHostname(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldHostname is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldHostname requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldHostname: %w", err) } - return oldValue.Name, nil + return oldValue.Hostname, nil } -// ResetName resets all changes to the "name" field. -func (m *FileMutation) ResetName() { - m.name = nil +// ClearHostname clears the value of the "hostname" field. +func (m *BeaconMutation) ClearHostname() { + m.hostname = nil + m.clearedFields[beacon.FieldHostname] = struct{}{} } -// SetSize sets the "size" field. -func (m *FileMutation) SetSize(i int) { - m.size = &i - m.addsize = nil +// HostnameCleared returns if the "hostname" field was cleared in this mutation. +func (m *BeaconMutation) HostnameCleared() bool { + _, ok := m.clearedFields[beacon.FieldHostname] + return ok } -// Size returns the value of the "size" field in the mutation. -func (m *FileMutation) Size() (r int, exists bool) { - v := m.size +// ResetHostname resets all changes to the "hostname" field. +func (m *BeaconMutation) ResetHostname() { + m.hostname = nil + delete(m.clearedFields, beacon.FieldHostname) +} + +// SetIdentifier sets the "identifier" field. +func (m *BeaconMutation) SetIdentifier(s string) { + m.identifier = &s +} + +// Identifier returns the value of the "identifier" field in the mutation. +func (m *BeaconMutation) Identifier() (r string, exists bool) { + v := m.identifier if v == nil { return } return *v, true } -// OldSize returns the old "size" field's value of the File entity. -// If the File object wasn't provided to the builder, the object is fetched from the database. +// OldIdentifier returns the old "identifier" field's value of the Beacon entity. +// If the Beacon 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 *FileMutation) OldSize(ctx context.Context) (v int, err error) { +func (m *BeaconMutation) OldIdentifier(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSize is only allowed on UpdateOne operations") + return v, errors.New("OldIdentifier 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") + return v, errors.New("OldIdentifier 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 *FileMutation) 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 *FileMutation) AddedSize() (r int, exists bool) { - v := m.addsize - if v == nil { - return + return v, fmt.Errorf("querying old value for OldIdentifier: %w", err) } - return *v, true + return oldValue.Identifier, nil } -// ResetSize resets all changes to the "size" field. -func (m *FileMutation) ResetSize() { - m.size = nil - m.addsize = nil +// ResetIdentifier resets all changes to the "identifier" field. +func (m *BeaconMutation) ResetIdentifier() { + m.identifier = nil } -// SetHash sets the "hash" field. -func (m *FileMutation) SetHash(s string) { - m.hash = &s +// SetAgentIdentifier sets the "agent_identifier" field. +func (m *BeaconMutation) SetAgentIdentifier(s string) { + m.agent_identifier = &s } -// Hash returns the value of the "hash" field in the mutation. -func (m *FileMutation) Hash() (r string, exists bool) { - v := m.hash +// AgentIdentifier returns the value of the "agent_identifier" field in the mutation. +func (m *BeaconMutation) AgentIdentifier() (r string, exists bool) { + v := m.agent_identifier if v == nil { return } return *v, true } -// OldHash returns the old "hash" field's value of the File entity. -// If the File object wasn't provided to the builder, the object is fetched from the database. +// OldAgentIdentifier returns the old "agent_identifier" field's value of the Beacon entity. +// If the Beacon 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 *FileMutation) OldHash(ctx context.Context) (v string, err error) { +func (m *BeaconMutation) OldAgentIdentifier(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHash is only allowed on UpdateOne operations") + return v, errors.New("OldAgentIdentifier 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") + return v, errors.New("OldAgentIdentifier 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 v, fmt.Errorf("querying old value for OldAgentIdentifier: %w", err) } - return oldValue.Hash, nil + return oldValue.AgentIdentifier, nil } -// ResetHash resets all changes to the "hash" field. -func (m *FileMutation) ResetHash() { - m.hash = nil +// ClearAgentIdentifier clears the value of the "agent_identifier" field. +func (m *BeaconMutation) ClearAgentIdentifier() { + m.agent_identifier = nil + m.clearedFields[beacon.FieldAgentIdentifier] = struct{}{} } -// SetContent sets the "content" field. -func (m *FileMutation) SetContent(b []byte) { - m.content = &b +// AgentIdentifierCleared returns if the "agent_identifier" field was cleared in this mutation. +func (m *BeaconMutation) AgentIdentifierCleared() bool { + _, ok := m.clearedFields[beacon.FieldAgentIdentifier] + return ok } -// Content returns the value of the "content" field in the mutation. -func (m *FileMutation) Content() (r []byte, exists bool) { - v := m.content +// ResetAgentIdentifier resets all changes to the "agent_identifier" field. +func (m *BeaconMutation) ResetAgentIdentifier() { + m.agent_identifier = nil + delete(m.clearedFields, beacon.FieldAgentIdentifier) +} + +// SetHostIdentifier sets the "host_identifier" field. +func (m *BeaconMutation) SetHostIdentifier(s string) { + m.host_identifier = &s +} + +// HostIdentifier returns the value of the "host_identifier" field in the mutation. +func (m *BeaconMutation) HostIdentifier() (r string, exists bool) { + v := m.host_identifier if v == nil { return } return *v, true } -// OldContent returns the old "content" field's value of the File entity. -// If the File object wasn't provided to the builder, the object is fetched from the database. +// OldHostIdentifier returns the old "host_identifier" field's value of the Beacon entity. +// If the Beacon 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 *FileMutation) OldContent(ctx context.Context) (v []byte, err error) { +func (m *BeaconMutation) OldHostIdentifier(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldContent is only allowed on UpdateOne operations") + return v, errors.New("OldHostIdentifier 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") + return v, errors.New("OldHostIdentifier 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 v, fmt.Errorf("querying old value for OldHostIdentifier: %w", err) } - return oldValue.Content, nil + return oldValue.HostIdentifier, nil } -// ResetContent resets all changes to the "content" field. -func (m *FileMutation) ResetContent() { - m.content = nil +// ClearHostIdentifier clears the value of the "host_identifier" field. +func (m *BeaconMutation) ClearHostIdentifier() { + m.host_identifier = nil + m.clearedFields[beacon.FieldHostIdentifier] = struct{}{} } -// Where appends a list predicates to the FileMutation builder. -func (m *FileMutation) Where(ps ...predicate.File) { - m.predicates = append(m.predicates, ps...) +// HostIdentifierCleared returns if the "host_identifier" field was cleared in this mutation. +func (m *BeaconMutation) HostIdentifierCleared() bool { + _, ok := m.clearedFields[beacon.FieldHostIdentifier] + return ok } -// WhereP appends storage-level predicates to the FileMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *FileMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.File, len(ps)) - for i := range ps { - p[i] = ps[i] +// ResetHostIdentifier resets all changes to the "host_identifier" field. +func (m *BeaconMutation) ResetHostIdentifier() { + m.host_identifier = nil + delete(m.clearedFields, beacon.FieldHostIdentifier) +} + +// SetHostPrimaryIP sets the "host_primary_ip" field. +func (m *BeaconMutation) SetHostPrimaryIP(s string) { + m.host_primary_ip = &s +} + +// HostPrimaryIP returns the value of the "host_primary_ip" field in the mutation. +func (m *BeaconMutation) HostPrimaryIP() (r string, exists bool) { + v := m.host_primary_ip + if v == nil { + return + } + return *v, true +} + +// OldHostPrimaryIP returns the old "host_primary_ip" field's value of the Beacon entity. +// If the Beacon 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 *BeaconMutation) OldHostPrimaryIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHostPrimaryIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHostPrimaryIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHostPrimaryIP: %w", err) + } + return oldValue.HostPrimaryIP, nil +} + +// ClearHostPrimaryIP clears the value of the "host_primary_ip" field. +func (m *BeaconMutation) ClearHostPrimaryIP() { + m.host_primary_ip = nil + m.clearedFields[beacon.FieldHostPrimaryIP] = struct{}{} +} + +// HostPrimaryIPCleared returns if the "host_primary_ip" field was cleared in this mutation. +func (m *BeaconMutation) HostPrimaryIPCleared() bool { + _, ok := m.clearedFields[beacon.FieldHostPrimaryIP] + return ok +} + +// ResetHostPrimaryIP resets all changes to the "host_primary_ip" field. +func (m *BeaconMutation) ResetHostPrimaryIP() { + m.host_primary_ip = nil + delete(m.clearedFields, beacon.FieldHostPrimaryIP) +} + +// SetHostPlatform sets the "host_platform" field. +func (m *BeaconMutation) SetHostPlatform(bp beacon.HostPlatform) { + m.host_platform = &bp +} + +// HostPlatform returns the value of the "host_platform" field in the mutation. +func (m *BeaconMutation) HostPlatform() (r beacon.HostPlatform, exists bool) { + v := m.host_platform + if v == nil { + return + } + return *v, true +} + +// OldHostPlatform returns the old "host_platform" field's value of the Beacon entity. +// If the Beacon 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 *BeaconMutation) OldHostPlatform(ctx context.Context) (v beacon.HostPlatform, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHostPlatform is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHostPlatform requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHostPlatform: %w", err) + } + return oldValue.HostPlatform, nil +} + +// ResetHostPlatform resets all changes to the "host_platform" field. +func (m *BeaconMutation) ResetHostPlatform() { + m.host_platform = nil +} + +// SetLastSeenAt sets the "last_seen_at" field. +func (m *BeaconMutation) SetLastSeenAt(t time.Time) { + m.last_seen_at = &t +} + +// LastSeenAt returns the value of the "last_seen_at" field in the mutation. +func (m *BeaconMutation) LastSeenAt() (r time.Time, exists bool) { + v := m.last_seen_at + if v == nil { + return + } + return *v, true +} + +// OldLastSeenAt returns the old "last_seen_at" field's value of the Beacon entity. +// If the Beacon 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 *BeaconMutation) OldLastSeenAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastSeenAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastSeenAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastSeenAt: %w", err) + } + return oldValue.LastSeenAt, nil +} + +// ClearLastSeenAt clears the value of the "last_seen_at" field. +func (m *BeaconMutation) ClearLastSeenAt() { + m.last_seen_at = nil + m.clearedFields[beacon.FieldLastSeenAt] = struct{}{} +} + +// LastSeenAtCleared returns if the "last_seen_at" field was cleared in this mutation. +func (m *BeaconMutation) LastSeenAtCleared() bool { + _, ok := m.clearedFields[beacon.FieldLastSeenAt] + return ok +} + +// ResetLastSeenAt resets all changes to the "last_seen_at" field. +func (m *BeaconMutation) ResetLastSeenAt() { + m.last_seen_at = nil + delete(m.clearedFields, beacon.FieldLastSeenAt) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *BeaconMutation) AddTagIDs(ids ...int) { + if m.tags == nil { + m.tags = make(map[int]struct{}) + } + for i := range ids { + m.tags[ids[i]] = struct{}{} + } +} + +// ClearTags clears the "tags" edge to the Tag entity. +func (m *BeaconMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *BeaconMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *BeaconMutation) RemoveTagIDs(ids ...int) { + if m.removedtags == nil { + m.removedtags = make(map[int]struct{}) + } + for i := range ids { + delete(m.tags, ids[i]) + m.removedtags[ids[i]] = struct{}{} + } +} + +// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. +func (m *BeaconMutation) RemovedTagsIDs() (ids []int) { + for id := range m.removedtags { + ids = append(ids, id) + } + return +} + +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *BeaconMutation) TagsIDs() (ids []int) { + for id := range m.tags { + ids = append(ids, id) + } + return +} + +// ResetTags resets all changes to the "tags" edge. +func (m *BeaconMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil +} + +// AddTaskIDs adds the "tasks" edge to the Task entity by ids. +func (m *BeaconMutation) AddTaskIDs(ids ...int) { + if m.tasks == nil { + m.tasks = make(map[int]struct{}) + } + for i := range ids { + m.tasks[ids[i]] = struct{}{} + } +} + +// ClearTasks clears the "tasks" edge to the Task entity. +func (m *BeaconMutation) ClearTasks() { + m.clearedtasks = true +} + +// TasksCleared reports if the "tasks" edge to the Task entity was cleared. +func (m *BeaconMutation) TasksCleared() bool { + return m.clearedtasks +} + +// RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs. +func (m *BeaconMutation) RemoveTaskIDs(ids ...int) { + if m.removedtasks == nil { + m.removedtasks = make(map[int]struct{}) + } + for i := range ids { + delete(m.tasks, ids[i]) + m.removedtasks[ids[i]] = struct{}{} + } +} + +// RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity. +func (m *BeaconMutation) RemovedTasksIDs() (ids []int) { + for id := range m.removedtasks { + ids = append(ids, id) + } + return +} + +// TasksIDs returns the "tasks" edge IDs in the mutation. +func (m *BeaconMutation) TasksIDs() (ids []int) { + for id := range m.tasks { + ids = append(ids, id) + } + return +} + +// ResetTasks resets all changes to the "tasks" edge. +func (m *BeaconMutation) ResetTasks() { + m.tasks = nil + m.clearedtasks = false + m.removedtasks = nil +} + +// Where appends a list predicates to the BeaconMutation builder. +func (m *BeaconMutation) Where(ps ...predicate.Beacon) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the BeaconMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *BeaconMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Beacon, len(ps)) + for i := range ps { + p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. -func (m *FileMutation) Op() Op { +func (m *BeaconMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *FileMutation) SetOp(op Op) { +func (m *BeaconMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (File). -func (m *FileMutation) Type() string { +// Type returns the node type of this mutation (Beacon). +func (m *BeaconMutation) 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 *FileMutation) Fields() []string { - fields := make([]string, 0, 6) - if m.created_at != nil { - fields = append(fields, file.FieldCreatedAt) +func (m *BeaconMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.name != nil { + fields = append(fields, beacon.FieldName) } - if m.last_modified_at != nil { - fields = append(fields, file.FieldLastModifiedAt) + if m.principal != nil { + fields = append(fields, beacon.FieldPrincipal) } - if m.name != nil { - fields = append(fields, file.FieldName) + if m.hostname != nil { + fields = append(fields, beacon.FieldHostname) } - if m.size != nil { - fields = append(fields, file.FieldSize) + if m.identifier != nil { + fields = append(fields, beacon.FieldIdentifier) } - if m.hash != nil { - fields = append(fields, file.FieldHash) + if m.agent_identifier != nil { + fields = append(fields, beacon.FieldAgentIdentifier) } - if m.content != nil { - fields = append(fields, file.FieldContent) + if m.host_identifier != nil { + fields = append(fields, beacon.FieldHostIdentifier) + } + if m.host_primary_ip != nil { + fields = append(fields, beacon.FieldHostPrimaryIP) + } + if m.host_platform != nil { + fields = append(fields, beacon.FieldHostPlatform) + } + if m.last_seen_at != nil { + fields = append(fields, beacon.FieldLastSeenAt) } return fields } @@ -451,20 +742,26 @@ func (m *FileMutation) 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 *FileMutation) Field(name string) (ent.Value, bool) { +func (m *BeaconMutation) Field(name string) (ent.Value, bool) { switch name { - case file.FieldCreatedAt: - return m.CreatedAt() - case file.FieldLastModifiedAt: - return m.LastModifiedAt() - case file.FieldName: + case beacon.FieldName: return m.Name() - case file.FieldSize: - return m.Size() - case file.FieldHash: - return m.Hash() - case file.FieldContent: - return m.Content() + case beacon.FieldPrincipal: + return m.Principal() + case beacon.FieldHostname: + return m.Hostname() + case beacon.FieldIdentifier: + return m.Identifier() + case beacon.FieldAgentIdentifier: + return m.AgentIdentifier() + case beacon.FieldHostIdentifier: + return m.HostIdentifier() + case beacon.FieldHostPrimaryIP: + return m.HostPrimaryIP() + case beacon.FieldHostPlatform: + return m.HostPlatform() + case beacon.FieldLastSeenAt: + return m.LastSeenAt() } return nil, false } @@ -472,207 +769,329 @@ func (m *FileMutation) 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 *FileMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *BeaconMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case file.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case file.FieldLastModifiedAt: - return m.OldLastModifiedAt(ctx) - case file.FieldName: + case beacon.FieldName: return m.OldName(ctx) - case file.FieldSize: - return m.OldSize(ctx) - case file.FieldHash: - return m.OldHash(ctx) - case file.FieldContent: - return m.OldContent(ctx) + case beacon.FieldPrincipal: + return m.OldPrincipal(ctx) + case beacon.FieldHostname: + return m.OldHostname(ctx) + case beacon.FieldIdentifier: + return m.OldIdentifier(ctx) + case beacon.FieldAgentIdentifier: + return m.OldAgentIdentifier(ctx) + case beacon.FieldHostIdentifier: + return m.OldHostIdentifier(ctx) + case beacon.FieldHostPrimaryIP: + return m.OldHostPrimaryIP(ctx) + case beacon.FieldHostPlatform: + return m.OldHostPlatform(ctx) + case beacon.FieldLastSeenAt: + return m.OldLastSeenAt(ctx) } - return nil, fmt.Errorf("unknown File field %s", name) + return nil, fmt.Errorf("unknown Beacon 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 *FileMutation) SetField(name string, value ent.Value) error { +func (m *BeaconMutation) SetField(name string, value ent.Value) error { switch name { - case file.FieldCreatedAt: - v, ok := value.(time.Time) + case beacon.FieldName: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetName(v) return nil - case file.FieldLastModifiedAt: - v, ok := value.(time.Time) + case beacon.FieldPrincipal: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetLastModifiedAt(v) + m.SetPrincipal(v) return nil - case file.FieldName: + case beacon.FieldHostname: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetName(v) + m.SetHostname(v) return nil - case file.FieldSize: - v, ok := value.(int) + case beacon.FieldIdentifier: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSize(v) + m.SetIdentifier(v) return nil - case file.FieldHash: + case beacon.FieldAgentIdentifier: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetHash(v) + m.SetAgentIdentifier(v) return nil - case file.FieldContent: - v, ok := value.([]byte) + case beacon.FieldHostIdentifier: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetContent(v) + m.SetHostIdentifier(v) + return nil + case beacon.FieldHostPrimaryIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHostPrimaryIP(v) + return nil + case beacon.FieldHostPlatform: + v, ok := value.(beacon.HostPlatform) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHostPlatform(v) + return nil + case beacon.FieldLastSeenAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastSeenAt(v) return nil } - return fmt.Errorf("unknown File field %s", name) + return fmt.Errorf("unknown Beacon field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *FileMutation) AddedFields() []string { - var fields []string - if m.addsize != nil { - fields = append(fields, file.FieldSize) - } - return fields +func (m *BeaconMutation) AddedFields() []string { + return nil } // 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 *FileMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case file.FieldSize: - return m.AddedSize() - } +func (m *BeaconMutation) AddedField(name string) (ent.Value, bool) { 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 *FileMutation) AddField(name string, value ent.Value) error { +func (m *BeaconMutation) AddField(name string, value ent.Value) error { switch name { - case file.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 File numeric field %s", name) + return fmt.Errorf("unknown Beacon numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *FileMutation) ClearedFields() []string { - return nil +func (m *BeaconMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(beacon.FieldPrincipal) { + fields = append(fields, beacon.FieldPrincipal) + } + if m.FieldCleared(beacon.FieldHostname) { + fields = append(fields, beacon.FieldHostname) + } + if m.FieldCleared(beacon.FieldAgentIdentifier) { + fields = append(fields, beacon.FieldAgentIdentifier) + } + if m.FieldCleared(beacon.FieldHostIdentifier) { + fields = append(fields, beacon.FieldHostIdentifier) + } + if m.FieldCleared(beacon.FieldHostPrimaryIP) { + fields = append(fields, beacon.FieldHostPrimaryIP) + } + if m.FieldCleared(beacon.FieldLastSeenAt) { + fields = append(fields, beacon.FieldLastSeenAt) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *FileMutation) FieldCleared(name string) bool { +func (m *BeaconMutation) 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 *FileMutation) ClearField(name string) error { - return fmt.Errorf("unknown File nullable field %s", name) +func (m *BeaconMutation) ClearField(name string) error { + switch name { + case beacon.FieldPrincipal: + m.ClearPrincipal() + return nil + case beacon.FieldHostname: + m.ClearHostname() + return nil + case beacon.FieldAgentIdentifier: + m.ClearAgentIdentifier() + return nil + case beacon.FieldHostIdentifier: + m.ClearHostIdentifier() + return nil + case beacon.FieldHostPrimaryIP: + m.ClearHostPrimaryIP() + return nil + case beacon.FieldLastSeenAt: + m.ClearLastSeenAt() + return nil + } + return fmt.Errorf("unknown Beacon 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 *FileMutation) ResetField(name string) error { +func (m *BeaconMutation) ResetField(name string) error { switch name { - case file.FieldCreatedAt: - m.ResetCreatedAt() + case beacon.FieldName: + m.ResetName() return nil - case file.FieldLastModifiedAt: - m.ResetLastModifiedAt() + case beacon.FieldPrincipal: + m.ResetPrincipal() + return nil + case beacon.FieldHostname: + m.ResetHostname() + return nil + case beacon.FieldIdentifier: + m.ResetIdentifier() + return nil + case beacon.FieldAgentIdentifier: + m.ResetAgentIdentifier() return nil - case file.FieldName: - m.ResetName() + case beacon.FieldHostIdentifier: + m.ResetHostIdentifier() return nil - case file.FieldSize: - m.ResetSize() + case beacon.FieldHostPrimaryIP: + m.ResetHostPrimaryIP() return nil - case file.FieldHash: - m.ResetHash() + case beacon.FieldHostPlatform: + m.ResetHostPlatform() return nil - case file.FieldContent: - m.ResetContent() + case beacon.FieldLastSeenAt: + m.ResetLastSeenAt() return nil } - return fmt.Errorf("unknown File field %s", name) + return fmt.Errorf("unknown Beacon field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *FileMutation) AddedEdges() []string { - edges := make([]string, 0, 0) +func (m *BeaconMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.tags != nil { + edges = append(edges, beacon.EdgeTags) + } + if m.tasks != nil { + edges = append(edges, beacon.EdgeTasks) + } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *FileMutation) AddedIDs(name string) []ent.Value { +func (m *BeaconMutation) AddedIDs(name string) []ent.Value { + switch name { + case beacon.EdgeTags: + ids := make([]ent.Value, 0, len(m.tags)) + for id := range m.tags { + ids = append(ids, id) + } + return ids + case beacon.EdgeTasks: + ids := make([]ent.Value, 0, len(m.tasks)) + for id := range m.tasks { + ids = append(ids, id) + } + return ids + } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *FileMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) +func (m *BeaconMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedtags != nil { + edges = append(edges, beacon.EdgeTags) + } + if m.removedtasks != nil { + edges = append(edges, beacon.EdgeTasks) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *FileMutation) RemovedIDs(name string) []ent.Value { +func (m *BeaconMutation) RemovedIDs(name string) []ent.Value { + switch name { + case beacon.EdgeTags: + ids := make([]ent.Value, 0, len(m.removedtags)) + for id := range m.removedtags { + ids = append(ids, id) + } + return ids + case beacon.EdgeTasks: + ids := make([]ent.Value, 0, len(m.removedtasks)) + for id := range m.removedtasks { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *FileMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) +func (m *BeaconMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedtags { + edges = append(edges, beacon.EdgeTags) + } + if m.clearedtasks { + edges = append(edges, beacon.EdgeTasks) + } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *FileMutation) EdgeCleared(name string) bool { +func (m *BeaconMutation) EdgeCleared(name string) bool { + switch name { + case beacon.EdgeTags: + return m.clearedtags + case beacon.EdgeTasks: + return m.clearedtasks + } 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 *FileMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown File unique edge %s", name) +func (m *BeaconMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Beacon 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 *FileMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown File edge %s", name) +func (m *BeaconMutation) ResetEdge(name string) error { + switch name { + case beacon.EdgeTags: + m.ResetTags() + return nil + case beacon.EdgeTasks: + m.ResetTasks() + return nil + } + return fmt.Errorf("unknown Beacon edge %s", name) } -// JobMutation represents an operation that mutates the Job nodes in the graph. -type JobMutation struct { +// FileMutation represents an operation that mutates the File nodes in the graph. +type FileMutation struct { config op Op typ string @@ -680,33 +1099,27 @@ type JobMutation struct { created_at *time.Time last_modified_at *time.Time name *string - parameters *string + size *int + addsize *int + hash *string + content *[]byte clearedFields map[string]struct{} - tome *int - clearedtome bool - bundle *int - clearedbundle bool - tasks map[int]struct{} - removedtasks map[int]struct{} - clearedtasks bool - creator *int - clearedcreator bool done bool - oldValue func(context.Context) (*Job, error) - predicates []predicate.Job + oldValue func(context.Context) (*File, error) + predicates []predicate.File } -var _ ent.Mutation = (*JobMutation)(nil) +var _ ent.Mutation = (*FileMutation)(nil) -// jobOption allows management of the mutation configuration using functional options. -type jobOption func(*JobMutation) +// fileOption allows management of the mutation configuration using functional options. +type fileOption func(*FileMutation) -// newJobMutation creates new mutation for the Job entity. -func newJobMutation(c config, op Op, opts ...jobOption) *JobMutation { - m := &JobMutation{ +// newFileMutation creates new mutation for the File entity. +func newFileMutation(c config, op Op, opts ...fileOption) *FileMutation { + m := &FileMutation{ config: c, op: op, - typ: TypeJob, + typ: TypeFile, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -715,20 +1128,20 @@ func newJobMutation(c config, op Op, opts ...jobOption) *JobMutation { return m } -// withJobID sets the ID field of the mutation. -func withJobID(id int) jobOption { - return func(m *JobMutation) { +// withFileID sets the ID field of the mutation. +func withFileID(id int) fileOption { + return func(m *FileMutation) { var ( err error once sync.Once - value *Job + value *File ) - m.oldValue = func(ctx context.Context) (*Job, error) { + m.oldValue = func(ctx context.Context) (*File, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Job.Get(ctx, id) + value, err = m.Client().File.Get(ctx, id) } }) return value, err @@ -737,10 +1150,10 @@ func withJobID(id int) jobOption { } } -// withJob sets the old Job of the mutation. -func withJob(node *Job) jobOption { - return func(m *JobMutation) { - m.oldValue = func(context.Context) (*Job, error) { +// withFile sets the old File of the mutation. +func withFile(node *File) fileOption { + return func(m *FileMutation) { + m.oldValue = func(context.Context) (*File, error) { return node, nil } m.id = &node.ID @@ -749,7 +1162,7 @@ func withJob(node *Job) jobOption { // 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 JobMutation) Client() *Client { +func (m FileMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -757,7 +1170,7 @@ func (m JobMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m JobMutation) Tx() (*Tx, error) { +func (m FileMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -768,7 +1181,7 @@ func (m JobMutation) 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 *JobMutation) ID() (id int, exists bool) { +func (m *FileMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -779,7 +1192,7 @@ func (m *JobMutation) 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 *JobMutation) IDs(ctx context.Context) ([]int, error) { +func (m *FileMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -788,19 +1201,19 @@ func (m *JobMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Job.Query().Where(m.predicates...).IDs(ctx) + return m.Client().File.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 *JobMutation) SetCreatedAt(t time.Time) { +func (m *FileMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *JobMutation) CreatedAt() (r time.Time, exists bool) { +func (m *FileMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -808,10 +1221,10 @@ func (m *JobMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Job entity. -// If the Job 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 File entity. +// If the File 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 *JobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *FileMutation) 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") } @@ -826,17 +1239,17 @@ func (m *JobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *JobMutation) ResetCreatedAt() { +func (m *FileMutation) ResetCreatedAt() { m.created_at = nil } // SetLastModifiedAt sets the "last_modified_at" field. -func (m *JobMutation) SetLastModifiedAt(t time.Time) { +func (m *FileMutation) SetLastModifiedAt(t time.Time) { m.last_modified_at = &t } // LastModifiedAt returns the value of the "last_modified_at" field in the mutation. -func (m *JobMutation) LastModifiedAt() (r time.Time, exists bool) { +func (m *FileMutation) LastModifiedAt() (r time.Time, exists bool) { v := m.last_modified_at if v == nil { return @@ -844,10 +1257,10 @@ func (m *JobMutation) LastModifiedAt() (r time.Time, exists bool) { return *v, true } -// OldLastModifiedAt returns the old "last_modified_at" field's value of the Job entity. -// If the Job 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 File entity. +// If the File 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 *JobMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { +func (m *FileMutation) 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") } @@ -862,17 +1275,17 @@ func (m *JobMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err e } // ResetLastModifiedAt resets all changes to the "last_modified_at" field. -func (m *JobMutation) ResetLastModifiedAt() { +func (m *FileMutation) ResetLastModifiedAt() { m.last_modified_at = nil } // SetName sets the "name" field. -func (m *JobMutation) SetName(s string) { +func (m *FileMutation) SetName(s string) { m.name = &s } // Name returns the value of the "name" field in the mutation. -func (m *JobMutation) Name() (r string, exists bool) { +func (m *FileMutation) Name() (r string, exists bool) { v := m.name if v == nil { return @@ -880,257 +1293,165 @@ func (m *JobMutation) Name() (r string, exists bool) { return *v, true } -// OldName returns the old "name" field's value of the Job entity. -// If the Job object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the File entity. +// If the File 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 *JobMutation) OldName(ctx context.Context) (v string, err error) { +func (m *FileMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldName is only allowed on UpdateOne operations") } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *JobMutation) ResetName() { - m.name = nil -} - -// SetParameters sets the "parameters" field. -func (m *JobMutation) SetParameters(s string) { - m.parameters = &s -} - -// Parameters returns the value of the "parameters" field in the mutation. -func (m *JobMutation) Parameters() (r string, exists bool) { - v := m.parameters - if v == nil { - return - } - return *v, true -} - -// OldParameters returns the old "parameters" field's value of the Job entity. -// If the Job 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 *JobMutation) OldParameters(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldParameters is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldParameters requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldParameters: %w", err) - } - return oldValue.Parameters, nil -} - -// ClearParameters clears the value of the "parameters" field. -func (m *JobMutation) ClearParameters() { - m.parameters = nil - m.clearedFields[job.FieldParameters] = struct{}{} -} - -// ParametersCleared returns if the "parameters" field was cleared in this mutation. -func (m *JobMutation) ParametersCleared() bool { - _, ok := m.clearedFields[job.FieldParameters] - return ok -} - -// ResetParameters resets all changes to the "parameters" field. -func (m *JobMutation) ResetParameters() { - m.parameters = nil - delete(m.clearedFields, job.FieldParameters) -} - -// SetTomeID sets the "tome" edge to the Tome entity by id. -func (m *JobMutation) SetTomeID(id int) { - m.tome = &id -} - -// ClearTome clears the "tome" edge to the Tome entity. -func (m *JobMutation) ClearTome() { - m.clearedtome = true -} - -// TomeCleared reports if the "tome" edge to the Tome entity was cleared. -func (m *JobMutation) TomeCleared() bool { - return m.clearedtome -} - -// TomeID returns the "tome" edge ID in the mutation. -func (m *JobMutation) TomeID() (id int, exists bool) { - if m.tome != nil { - return *m.tome, true - } - return -} - -// TomeIDs returns the "tome" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TomeID instead. It exists only for internal usage by the builders. -func (m *JobMutation) TomeIDs() (ids []int) { - if id := m.tome; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetTome resets all changes to the "tome" edge. -func (m *JobMutation) ResetTome() { - m.tome = nil - m.clearedtome = false -} - -// SetBundleID sets the "bundle" edge to the File entity by id. -func (m *JobMutation) SetBundleID(id int) { - m.bundle = &id -} - -// ClearBundle clears the "bundle" edge to the File entity. -func (m *JobMutation) ClearBundle() { - m.clearedbundle = true -} - -// BundleCleared reports if the "bundle" edge to the File entity was cleared. -func (m *JobMutation) BundleCleared() bool { - return m.clearedbundle -} - -// BundleID returns the "bundle" edge ID in the mutation. -func (m *JobMutation) BundleID() (id int, exists bool) { - if m.bundle != nil { - return *m.bundle, true - } - return -} - -// BundleIDs returns the "bundle" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// BundleID instead. It exists only for internal usage by the builders. -func (m *JobMutation) BundleIDs() (ids []int) { - if id := m.bundle; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetBundle resets all changes to the "bundle" edge. -func (m *JobMutation) ResetBundle() { - m.bundle = nil - m.clearedbundle = false -} - -// AddTaskIDs adds the "tasks" edge to the Task entity by ids. -func (m *JobMutation) AddTaskIDs(ids ...int) { - if m.tasks == nil { - m.tasks = make(map[int]struct{}) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") } - for i := range ids { - m.tasks[ids[i]] = struct{}{} + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) } + return oldValue.Name, nil } -// ClearTasks clears the "tasks" edge to the Task entity. -func (m *JobMutation) ClearTasks() { - m.clearedtasks = true +// ResetName resets all changes to the "name" field. +func (m *FileMutation) ResetName() { + m.name = nil } -// TasksCleared reports if the "tasks" edge to the Task entity was cleared. -func (m *JobMutation) TasksCleared() bool { - return m.clearedtasks +// SetSize sets the "size" field. +func (m *FileMutation) SetSize(i int) { + m.size = &i + m.addsize = nil } -// RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs. -func (m *JobMutation) RemoveTaskIDs(ids ...int) { - if m.removedtasks == nil { - m.removedtasks = make(map[int]struct{}) +// Size returns the value of the "size" field in the mutation. +func (m *FileMutation) Size() (r int, exists bool) { + v := m.size + if v == nil { + return } - for i := range ids { - delete(m.tasks, ids[i]) - m.removedtasks[ids[i]] = struct{}{} + return *v, true +} + +// OldSize returns the old "size" field's value of the File entity. +// If the File 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 *FileMutation) 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 } -// RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity. -func (m *JobMutation) RemovedTasksIDs() (ids []int) { - for id := range m.removedtasks { - ids = append(ids, id) +// AddSize adds i to the "size" field. +func (m *FileMutation) AddSize(i int) { + if m.addsize != nil { + *m.addsize += i + } else { + m.addsize = &i } - return } -// TasksIDs returns the "tasks" edge IDs in the mutation. -func (m *JobMutation) TasksIDs() (ids []int) { - for id := range m.tasks { - ids = append(ids, id) +// AddedSize returns the value that was added to the "size" field in this mutation. +func (m *FileMutation) AddedSize() (r int, exists bool) { + v := m.addsize + if v == nil { + return } - return + return *v, true } -// ResetTasks resets all changes to the "tasks" edge. -func (m *JobMutation) ResetTasks() { - m.tasks = nil - m.clearedtasks = false - m.removedtasks = nil +// ResetSize resets all changes to the "size" field. +func (m *FileMutation) ResetSize() { + m.size = nil + m.addsize = nil } -// SetCreatorID sets the "creator" edge to the User entity by id. -func (m *JobMutation) SetCreatorID(id int) { - m.creator = &id +// SetHash sets the "hash" field. +func (m *FileMutation) SetHash(s string) { + m.hash = &s } -// ClearCreator clears the "creator" edge to the User entity. -func (m *JobMutation) ClearCreator() { - m.clearedcreator = true +// Hash returns the value of the "hash" field in the mutation. +func (m *FileMutation) Hash() (r string, exists bool) { + v := m.hash + if v == nil { + return + } + return *v, true } -// CreatorCleared reports if the "creator" edge to the User entity was cleared. -func (m *JobMutation) CreatorCleared() bool { - return m.clearedcreator +// OldHash returns the old "hash" field's value of the File entity. +// If the File 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 *FileMutation) 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 } -// CreatorID returns the "creator" edge ID in the mutation. -func (m *JobMutation) CreatorID() (id int, exists bool) { - if m.creator != nil { - return *m.creator, true +// ResetHash resets all changes to the "hash" field. +func (m *FileMutation) ResetHash() { + m.hash = nil +} + +// SetContent sets the "content" field. +func (m *FileMutation) SetContent(b []byte) { + m.content = &b +} + +// Content returns the value of the "content" field in the mutation. +func (m *FileMutation) Content() (r []byte, exists bool) { + v := m.content + if v == nil { + return } - return + return *v, true } -// CreatorIDs returns the "creator" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// CreatorID instead. It exists only for internal usage by the builders. -func (m *JobMutation) CreatorIDs() (ids []int) { - if id := m.creator; id != nil { - ids = append(ids, *id) +// OldContent returns the old "content" field's value of the File entity. +// If the File 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 *FileMutation) OldContent(ctx context.Context) (v []byte, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldContent is only allowed on UpdateOne operations") } - return + 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 } -// ResetCreator resets all changes to the "creator" edge. -func (m *JobMutation) ResetCreator() { - m.creator = nil - m.clearedcreator = false +// ResetContent resets all changes to the "content" field. +func (m *FileMutation) ResetContent() { + m.content = nil } -// Where appends a list predicates to the JobMutation builder. -func (m *JobMutation) Where(ps ...predicate.Job) { +// Where appends a list predicates to the FileMutation builder. +func (m *FileMutation) Where(ps ...predicate.File) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the JobMutation builder. Using this method, +// WhereP appends storage-level predicates to the FileMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *JobMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Job, len(ps)) +func (m *FileMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.File, len(ps)) for i := range ps { p[i] = ps[i] } @@ -1138,36 +1459,42 @@ func (m *JobMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *JobMutation) Op() Op { +func (m *FileMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *JobMutation) SetOp(op Op) { +func (m *FileMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Job). -func (m *JobMutation) Type() string { +// Type returns the node type of this mutation (File). +func (m *FileMutation) 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 *JobMutation) Fields() []string { - fields := make([]string, 0, 4) +func (m *FileMutation) Fields() []string { + fields := make([]string, 0, 6) if m.created_at != nil { - fields = append(fields, job.FieldCreatedAt) + fields = append(fields, file.FieldCreatedAt) } if m.last_modified_at != nil { - fields = append(fields, job.FieldLastModifiedAt) + fields = append(fields, file.FieldLastModifiedAt) } if m.name != nil { - fields = append(fields, job.FieldName) + fields = append(fields, file.FieldName) } - if m.parameters != nil { - fields = append(fields, job.FieldParameters) + if m.size != nil { + fields = append(fields, file.FieldSize) + } + if m.hash != nil { + fields = append(fields, file.FieldHash) + } + if m.content != nil { + fields = append(fields, file.FieldContent) } return fields } @@ -1175,16 +1502,20 @@ func (m *JobMutation) 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 *JobMutation) Field(name string) (ent.Value, bool) { +func (m *FileMutation) Field(name string) (ent.Value, bool) { switch name { - case job.FieldCreatedAt: + case file.FieldCreatedAt: return m.CreatedAt() - case job.FieldLastModifiedAt: + case file.FieldLastModifiedAt: return m.LastModifiedAt() - case job.FieldName: + case file.FieldName: return m.Name() - case job.FieldParameters: - return m.Parameters() + case file.FieldSize: + return m.Size() + case file.FieldHash: + return m.Hash() + case file.FieldContent: + return m.Content() } return nil, false } @@ -1192,848 +1523,565 @@ func (m *JobMutation) 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 *JobMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *FileMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case job.FieldCreatedAt: + case file.FieldCreatedAt: return m.OldCreatedAt(ctx) - case job.FieldLastModifiedAt: + case file.FieldLastModifiedAt: return m.OldLastModifiedAt(ctx) - case job.FieldName: + case file.FieldName: return m.OldName(ctx) - case job.FieldParameters: - return m.OldParameters(ctx) + case file.FieldSize: + return m.OldSize(ctx) + case file.FieldHash: + return m.OldHash(ctx) + case file.FieldContent: + return m.OldContent(ctx) } - return nil, fmt.Errorf("unknown Job field %s", name) + return nil, fmt.Errorf("unknown File 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 *JobMutation) SetField(name string, value ent.Value) error { +func (m *FileMutation) SetField(name string, value ent.Value) error { switch name { - case job.FieldCreatedAt: + case file.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 job.FieldLastModifiedAt: + case file.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 job.FieldName: + case file.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetName(v) return nil - case job.FieldParameters: + case file.FieldSize: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSize(v) + return nil + case file.FieldHash: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetParameters(v) + m.SetHash(v) + return nil + case file.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 Job field %s", name) + return fmt.Errorf("unknown File field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *JobMutation) AddedFields() []string { - return nil +func (m *FileMutation) AddedFields() []string { + var fields []string + if m.addsize != nil { + fields = append(fields, file.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 *JobMutation) AddedField(name string) (ent.Value, bool) { +func (m *FileMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case file.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 *JobMutation) AddField(name string, value ent.Value) error { +func (m *FileMutation) AddField(name string, value ent.Value) error { switch name { + case file.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 Job numeric field %s", name) + return fmt.Errorf("unknown File numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *JobMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(job.FieldParameters) { - fields = append(fields, job.FieldParameters) - } - return fields +func (m *FileMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *JobMutation) FieldCleared(name string) bool { +func (m *FileMutation) 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 *JobMutation) ClearField(name string) error { - switch name { - case job.FieldParameters: - m.ClearParameters() - return nil - } - return fmt.Errorf("unknown Job nullable field %s", name) +func (m *FileMutation) ClearField(name string) error { + return fmt.Errorf("unknown File 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 *JobMutation) ResetField(name string) error { +func (m *FileMutation) ResetField(name string) error { switch name { - case job.FieldCreatedAt: + case file.FieldCreatedAt: m.ResetCreatedAt() return nil - case job.FieldLastModifiedAt: + case file.FieldLastModifiedAt: m.ResetLastModifiedAt() return nil - case job.FieldName: + case file.FieldName: m.ResetName() return nil - case job.FieldParameters: - m.ResetParameters() + case file.FieldSize: + m.ResetSize() + return nil + case file.FieldHash: + m.ResetHash() + return nil + case file.FieldContent: + m.ResetContent() return nil } - return fmt.Errorf("unknown Job field %s", name) + return fmt.Errorf("unknown File field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *JobMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.tome != nil { - edges = append(edges, job.EdgeTome) - } - if m.bundle != nil { - edges = append(edges, job.EdgeBundle) - } - if m.tasks != nil { - edges = append(edges, job.EdgeTasks) - } - if m.creator != nil { - edges = append(edges, job.EdgeCreator) - } +func (m *FileMutation) AddedEdges() []string { + edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *JobMutation) AddedIDs(name string) []ent.Value { - switch name { - case job.EdgeTome: - if id := m.tome; id != nil { - return []ent.Value{*id} - } - case job.EdgeBundle: - if id := m.bundle; id != nil { - return []ent.Value{*id} - } - case job.EdgeTasks: - ids := make([]ent.Value, 0, len(m.tasks)) - for id := range m.tasks { - ids = append(ids, id) - } - return ids - case job.EdgeCreator: - if id := m.creator; id != nil { - return []ent.Value{*id} - } - } +func (m *FileMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *JobMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedtasks != nil { - edges = append(edges, job.EdgeTasks) - } +func (m *FileMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *JobMutation) RemovedIDs(name string) []ent.Value { - switch name { - case job.EdgeTasks: - ids := make([]ent.Value, 0, len(m.removedtasks)) - for id := range m.removedtasks { - ids = append(ids, id) - } - return ids - } +func (m *FileMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *JobMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedtome { - edges = append(edges, job.EdgeTome) - } - if m.clearedbundle { - edges = append(edges, job.EdgeBundle) - } - if m.clearedtasks { - edges = append(edges, job.EdgeTasks) - } - if m.clearedcreator { - edges = append(edges, job.EdgeCreator) - } +func (m *FileMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *JobMutation) EdgeCleared(name string) bool { - switch name { - case job.EdgeTome: - return m.clearedtome - case job.EdgeBundle: - return m.clearedbundle - case job.EdgeTasks: - return m.clearedtasks - case job.EdgeCreator: - return m.clearedcreator - } +func (m *FileMutation) EdgeCleared(name string) bool { 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 *JobMutation) ClearEdge(name string) error { - switch name { - case job.EdgeTome: - m.ClearTome() - return nil - case job.EdgeBundle: - m.ClearBundle() - return nil - case job.EdgeCreator: - m.ClearCreator() - return nil - } - return fmt.Errorf("unknown Job unique edge %s", name) +func (m *FileMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown File 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 *JobMutation) ResetEdge(name string) error { - switch name { - case job.EdgeTome: - m.ResetTome() - return nil - case job.EdgeBundle: - m.ResetBundle() - return nil - case job.EdgeTasks: - m.ResetTasks() - return nil - case job.EdgeCreator: - m.ResetCreator() - return nil - } - return fmt.Errorf("unknown Job edge %s", name) +func (m *FileMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown File edge %s", name) } -// SessionMutation represents an operation that mutates the Session nodes in the graph. -type SessionMutation struct { +// QuestMutation represents an operation that mutates the Quest nodes in the graph. +type QuestMutation struct { config op Op typ string id *int + created_at *time.Time + last_modified_at *time.Time name *string - principal *string - hostname *string - identifier *string - agent_identifier *string - host_identifier *string - host_primary_ip *string - host_platform *session.HostPlatform - last_seen_at *time.Time + parameters *string clearedFields map[string]struct{} - tags map[int]struct{} - removedtags map[int]struct{} - clearedtags bool + tome *int + clearedtome bool + bundle *int + clearedbundle bool tasks map[int]struct{} removedtasks map[int]struct{} - clearedtasks bool - done bool - oldValue func(context.Context) (*Session, error) - predicates []predicate.Session -} - -var _ ent.Mutation = (*SessionMutation)(nil) - -// sessionOption allows management of the mutation configuration using functional options. -type sessionOption func(*SessionMutation) - -// newSessionMutation creates new mutation for the Session entity. -func newSessionMutation(c config, op Op, opts ...sessionOption) *SessionMutation { - m := &SessionMutation{ - config: c, - op: op, - typ: TypeSession, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withSessionID sets the ID field of the mutation. -func withSessionID(id int) sessionOption { - return func(m *SessionMutation) { - var ( - err error - once sync.Once - value *Session - ) - m.oldValue = func(ctx context.Context) (*Session, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Session.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withSession sets the old Session of the mutation. -func withSession(node *Session) sessionOption { - return func(m *SessionMutation) { - m.oldValue = func(context.Context) (*Session, 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 SessionMutation) 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 SessionMutation) 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 *SessionMutation) 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 *SessionMutation) 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().Session.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetName sets the "name" field. -func (m *SessionMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *SessionMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Session entity. -// If the Session 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 *SessionMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *SessionMutation) ResetName() { - m.name = nil -} - -// SetPrincipal sets the "principal" field. -func (m *SessionMutation) SetPrincipal(s string) { - m.principal = &s -} - -// Principal returns the value of the "principal" field in the mutation. -func (m *SessionMutation) Principal() (r string, exists bool) { - v := m.principal - if v == nil { - return - } - return *v, true -} - -// OldPrincipal returns the old "principal" field's value of the Session entity. -// If the Session 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 *SessionMutation) OldPrincipal(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPrincipal is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPrincipal requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPrincipal: %w", err) - } - return oldValue.Principal, nil -} - -// ClearPrincipal clears the value of the "principal" field. -func (m *SessionMutation) ClearPrincipal() { - m.principal = nil - m.clearedFields[session.FieldPrincipal] = struct{}{} -} - -// PrincipalCleared returns if the "principal" field was cleared in this mutation. -func (m *SessionMutation) PrincipalCleared() bool { - _, ok := m.clearedFields[session.FieldPrincipal] - return ok -} - -// ResetPrincipal resets all changes to the "principal" field. -func (m *SessionMutation) ResetPrincipal() { - m.principal = nil - delete(m.clearedFields, session.FieldPrincipal) + clearedtasks bool + creator *int + clearedcreator bool + done bool + oldValue func(context.Context) (*Quest, error) + predicates []predicate.Quest } -// SetHostname sets the "hostname" field. -func (m *SessionMutation) SetHostname(s string) { - m.hostname = &s -} +var _ ent.Mutation = (*QuestMutation)(nil) -// Hostname returns the value of the "hostname" field in the mutation. -func (m *SessionMutation) Hostname() (r string, exists bool) { - v := m.hostname - if v == nil { - return - } - return *v, true -} +// questOption allows management of the mutation configuration using functional options. +type questOption func(*QuestMutation) -// OldHostname returns the old "hostname" field's value of the Session entity. -// If the Session 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 *SessionMutation) OldHostname(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHostname is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHostname requires an ID field in the mutation") +// newQuestMutation creates new mutation for the Quest entity. +func newQuestMutation(c config, op Op, opts ...questOption) *QuestMutation { + m := &QuestMutation{ + config: c, + op: op, + typ: TypeQuest, + clearedFields: make(map[string]struct{}), } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldHostname: %w", err) + for _, opt := range opts { + opt(m) } - return oldValue.Hostname, nil + return m } -// ClearHostname clears the value of the "hostname" field. -func (m *SessionMutation) ClearHostname() { - m.hostname = nil - m.clearedFields[session.FieldHostname] = struct{}{} +// withQuestID sets the ID field of the mutation. +func withQuestID(id int) questOption { + return func(m *QuestMutation) { + var ( + err error + once sync.Once + value *Quest + ) + m.oldValue = func(ctx context.Context) (*Quest, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Quest.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } } -// HostnameCleared returns if the "hostname" field was cleared in this mutation. -func (m *SessionMutation) HostnameCleared() bool { - _, ok := m.clearedFields[session.FieldHostname] - return ok +// withQuest sets the old Quest of the mutation. +func withQuest(node *Quest) questOption { + return func(m *QuestMutation) { + m.oldValue = func(context.Context) (*Quest, error) { + return node, nil + } + m.id = &node.ID + } } -// ResetHostname resets all changes to the "hostname" field. -func (m *SessionMutation) ResetHostname() { - m.hostname = nil - delete(m.clearedFields, session.FieldHostname) +// 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 QuestMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// SetIdentifier sets the "identifier" field. -func (m *SessionMutation) SetIdentifier(s string) { - m.identifier = &s +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m QuestMutation) 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 } -// Identifier returns the value of the "identifier" field in the mutation. -func (m *SessionMutation) Identifier() (r string, exists bool) { - v := m.identifier - if v == 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 *QuestMutation) ID() (id int, exists bool) { + if m.id == nil { return } - return *v, true + return *m.id, true } -// OldIdentifier returns the old "identifier" field's value of the Session entity. -// If the Session 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 *SessionMutation) OldIdentifier(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIdentifier is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIdentifier requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIdentifier: %w", err) +// 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 *QuestMutation) 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().Quest.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } - return oldValue.Identifier, nil -} - -// ResetIdentifier resets all changes to the "identifier" field. -func (m *SessionMutation) ResetIdentifier() { - m.identifier = nil } -// SetAgentIdentifier sets the "agent_identifier" field. -func (m *SessionMutation) SetAgentIdentifier(s string) { - m.agent_identifier = &s +// SetCreatedAt sets the "created_at" field. +func (m *QuestMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// AgentIdentifier returns the value of the "agent_identifier" field in the mutation. -func (m *SessionMutation) AgentIdentifier() (r string, exists bool) { - v := m.agent_identifier +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *QuestMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldAgentIdentifier returns the old "agent_identifier" field's value of the Session entity. -// If the Session 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 Quest entity. +// If the Quest 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 *SessionMutation) OldAgentIdentifier(ctx context.Context) (v string, err error) { +func (m *QuestMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAgentIdentifier is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAgentIdentifier requires an ID field in the mutation") + 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 OldAgentIdentifier: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.AgentIdentifier, nil -} - -// ClearAgentIdentifier clears the value of the "agent_identifier" field. -func (m *SessionMutation) ClearAgentIdentifier() { - m.agent_identifier = nil - m.clearedFields[session.FieldAgentIdentifier] = struct{}{} -} - -// AgentIdentifierCleared returns if the "agent_identifier" field was cleared in this mutation. -func (m *SessionMutation) AgentIdentifierCleared() bool { - _, ok := m.clearedFields[session.FieldAgentIdentifier] - return ok + return oldValue.CreatedAt, nil } -// ResetAgentIdentifier resets all changes to the "agent_identifier" field. -func (m *SessionMutation) ResetAgentIdentifier() { - m.agent_identifier = nil - delete(m.clearedFields, session.FieldAgentIdentifier) +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *QuestMutation) ResetCreatedAt() { + m.created_at = nil } -// SetHostIdentifier sets the "host_identifier" field. -func (m *SessionMutation) SetHostIdentifier(s string) { - m.host_identifier = &s +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *QuestMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t } -// HostIdentifier returns the value of the "host_identifier" field in the mutation. -func (m *SessionMutation) HostIdentifier() (r string, exists bool) { - v := m.host_identifier +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *QuestMutation) LastModifiedAt() (r time.Time, exists bool) { + v := m.last_modified_at if v == nil { return } return *v, true } -// OldHostIdentifier returns the old "host_identifier" field's value of the Session entity. -// If the Session 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 Quest entity. +// If the Quest 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 *SessionMutation) OldHostIdentifier(ctx context.Context) (v string, err error) { +func (m *QuestMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHostIdentifier is only allowed on UpdateOne operations") + return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHostIdentifier requires an ID field in the mutation") + 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 OldHostIdentifier: %w", err) + return v, fmt.Errorf("querying old value for OldLastModifiedAt: %w", err) } - return oldValue.HostIdentifier, nil -} - -// ClearHostIdentifier clears the value of the "host_identifier" field. -func (m *SessionMutation) ClearHostIdentifier() { - m.host_identifier = nil - m.clearedFields[session.FieldHostIdentifier] = struct{}{} -} - -// HostIdentifierCleared returns if the "host_identifier" field was cleared in this mutation. -func (m *SessionMutation) HostIdentifierCleared() bool { - _, ok := m.clearedFields[session.FieldHostIdentifier] - return ok + return oldValue.LastModifiedAt, nil } -// ResetHostIdentifier resets all changes to the "host_identifier" field. -func (m *SessionMutation) ResetHostIdentifier() { - m.host_identifier = nil - delete(m.clearedFields, session.FieldHostIdentifier) +// ResetLastModifiedAt resets all changes to the "last_modified_at" field. +func (m *QuestMutation) ResetLastModifiedAt() { + m.last_modified_at = nil } -// SetHostPrimaryIP sets the "host_primary_ip" field. -func (m *SessionMutation) SetHostPrimaryIP(s string) { - m.host_primary_ip = &s +// SetName sets the "name" field. +func (m *QuestMutation) SetName(s string) { + m.name = &s } -// HostPrimaryIP returns the value of the "host_primary_ip" field in the mutation. -func (m *SessionMutation) HostPrimaryIP() (r string, exists bool) { - v := m.host_primary_ip +// Name returns the value of the "name" field in the mutation. +func (m *QuestMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldHostPrimaryIP returns the old "host_primary_ip" field's value of the Session entity. -// If the Session object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Quest entity. +// If the Quest 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 *SessionMutation) OldHostPrimaryIP(ctx context.Context) (v string, err error) { +func (m *QuestMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHostPrimaryIP is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHostPrimaryIP requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldHostPrimaryIP: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.HostPrimaryIP, nil -} - -// ClearHostPrimaryIP clears the value of the "host_primary_ip" field. -func (m *SessionMutation) ClearHostPrimaryIP() { - m.host_primary_ip = nil - m.clearedFields[session.FieldHostPrimaryIP] = struct{}{} -} - -// HostPrimaryIPCleared returns if the "host_primary_ip" field was cleared in this mutation. -func (m *SessionMutation) HostPrimaryIPCleared() bool { - _, ok := m.clearedFields[session.FieldHostPrimaryIP] - return ok + return oldValue.Name, nil } -// ResetHostPrimaryIP resets all changes to the "host_primary_ip" field. -func (m *SessionMutation) ResetHostPrimaryIP() { - m.host_primary_ip = nil - delete(m.clearedFields, session.FieldHostPrimaryIP) +// ResetName resets all changes to the "name" field. +func (m *QuestMutation) ResetName() { + m.name = nil } -// SetHostPlatform sets the "host_platform" field. -func (m *SessionMutation) SetHostPlatform(sp session.HostPlatform) { - m.host_platform = &sp +// SetParameters sets the "parameters" field. +func (m *QuestMutation) SetParameters(s string) { + m.parameters = &s } -// HostPlatform returns the value of the "host_platform" field in the mutation. -func (m *SessionMutation) HostPlatform() (r session.HostPlatform, exists bool) { - v := m.host_platform +// Parameters returns the value of the "parameters" field in the mutation. +func (m *QuestMutation) Parameters() (r string, exists bool) { + v := m.parameters if v == nil { return } return *v, true } -// OldHostPlatform returns the old "host_platform" field's value of the Session entity. -// If the Session object wasn't provided to the builder, the object is fetched from the database. +// OldParameters returns the old "parameters" field's value of the Quest entity. +// If the Quest 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 *SessionMutation) OldHostPlatform(ctx context.Context) (v session.HostPlatform, err error) { +func (m *QuestMutation) OldParameters(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHostPlatform is only allowed on UpdateOne operations") + return v, errors.New("OldParameters is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHostPlatform requires an ID field in the mutation") + return v, errors.New("OldParameters requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldHostPlatform: %w", err) + return v, fmt.Errorf("querying old value for OldParameters: %w", err) } - return oldValue.HostPlatform, nil + return oldValue.Parameters, nil } -// ResetHostPlatform resets all changes to the "host_platform" field. -func (m *SessionMutation) ResetHostPlatform() { - m.host_platform = nil +// ClearParameters clears the value of the "parameters" field. +func (m *QuestMutation) ClearParameters() { + m.parameters = nil + m.clearedFields[quest.FieldParameters] = struct{}{} } -// SetLastSeenAt sets the "last_seen_at" field. -func (m *SessionMutation) SetLastSeenAt(t time.Time) { - m.last_seen_at = &t +// ParametersCleared returns if the "parameters" field was cleared in this mutation. +func (m *QuestMutation) ParametersCleared() bool { + _, ok := m.clearedFields[quest.FieldParameters] + return ok } -// LastSeenAt returns the value of the "last_seen_at" field in the mutation. -func (m *SessionMutation) LastSeenAt() (r time.Time, exists bool) { - v := m.last_seen_at - if v == nil { - return - } - return *v, true +// ResetParameters resets all changes to the "parameters" field. +func (m *QuestMutation) ResetParameters() { + m.parameters = nil + delete(m.clearedFields, quest.FieldParameters) } -// OldLastSeenAt returns the old "last_seen_at" field's value of the Session entity. -// If the Session 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 *SessionMutation) OldLastSeenAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastSeenAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastSeenAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastSeenAt: %w", err) - } - return oldValue.LastSeenAt, nil +// SetTomeID sets the "tome" edge to the Tome entity by id. +func (m *QuestMutation) SetTomeID(id int) { + m.tome = &id } -// ClearLastSeenAt clears the value of the "last_seen_at" field. -func (m *SessionMutation) ClearLastSeenAt() { - m.last_seen_at = nil - m.clearedFields[session.FieldLastSeenAt] = struct{}{} +// ClearTome clears the "tome" edge to the Tome entity. +func (m *QuestMutation) ClearTome() { + m.clearedtome = true } -// LastSeenAtCleared returns if the "last_seen_at" field was cleared in this mutation. -func (m *SessionMutation) LastSeenAtCleared() bool { - _, ok := m.clearedFields[session.FieldLastSeenAt] - return ok +// TomeCleared reports if the "tome" edge to the Tome entity was cleared. +func (m *QuestMutation) TomeCleared() bool { + return m.clearedtome } -// ResetLastSeenAt resets all changes to the "last_seen_at" field. -func (m *SessionMutation) ResetLastSeenAt() { - m.last_seen_at = nil - delete(m.clearedFields, session.FieldLastSeenAt) +// TomeID returns the "tome" edge ID in the mutation. +func (m *QuestMutation) TomeID() (id int, exists bool) { + if m.tome != nil { + return *m.tome, true + } + return +} + +// TomeIDs returns the "tome" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TomeID instead. It exists only for internal usage by the builders. +func (m *QuestMutation) TomeIDs() (ids []int) { + if id := m.tome; id != nil { + ids = append(ids, *id) + } + return } -// AddTagIDs adds the "tags" edge to the Tag entity by ids. -func (m *SessionMutation) AddTagIDs(ids ...int) { - if m.tags == nil { - m.tags = make(map[int]struct{}) - } - for i := range ids { - m.tags[ids[i]] = struct{}{} - } +// ResetTome resets all changes to the "tome" edge. +func (m *QuestMutation) ResetTome() { + m.tome = nil + m.clearedtome = false } -// ClearTags clears the "tags" edge to the Tag entity. -func (m *SessionMutation) ClearTags() { - m.clearedtags = true +// SetBundleID sets the "bundle" edge to the File entity by id. +func (m *QuestMutation) SetBundleID(id int) { + m.bundle = &id } -// TagsCleared reports if the "tags" edge to the Tag entity was cleared. -func (m *SessionMutation) TagsCleared() bool { - return m.clearedtags +// ClearBundle clears the "bundle" edge to the File entity. +func (m *QuestMutation) ClearBundle() { + m.clearedbundle = true } -// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. -func (m *SessionMutation) RemoveTagIDs(ids ...int) { - if m.removedtags == nil { - m.removedtags = make(map[int]struct{}) - } - for i := range ids { - delete(m.tags, ids[i]) - m.removedtags[ids[i]] = struct{}{} - } +// BundleCleared reports if the "bundle" edge to the File entity was cleared. +func (m *QuestMutation) BundleCleared() bool { + return m.clearedbundle } -// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. -func (m *SessionMutation) RemovedTagsIDs() (ids []int) { - for id := range m.removedtags { - ids = append(ids, id) +// BundleID returns the "bundle" edge ID in the mutation. +func (m *QuestMutation) BundleID() (id int, exists bool) { + if m.bundle != nil { + return *m.bundle, true } return } -// TagsIDs returns the "tags" edge IDs in the mutation. -func (m *SessionMutation) TagsIDs() (ids []int) { - for id := range m.tags { - ids = append(ids, id) +// BundleIDs returns the "bundle" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// BundleID instead. It exists only for internal usage by the builders. +func (m *QuestMutation) BundleIDs() (ids []int) { + if id := m.bundle; id != nil { + ids = append(ids, *id) } return } -// ResetTags resets all changes to the "tags" edge. -func (m *SessionMutation) ResetTags() { - m.tags = nil - m.clearedtags = false - m.removedtags = nil +// ResetBundle resets all changes to the "bundle" edge. +func (m *QuestMutation) ResetBundle() { + m.bundle = nil + m.clearedbundle = false } // AddTaskIDs adds the "tasks" edge to the Task entity by ids. -func (m *SessionMutation) AddTaskIDs(ids ...int) { +func (m *QuestMutation) AddTaskIDs(ids ...int) { if m.tasks == nil { m.tasks = make(map[int]struct{}) } @@ -2043,17 +2091,17 @@ func (m *SessionMutation) AddTaskIDs(ids ...int) { } // ClearTasks clears the "tasks" edge to the Task entity. -func (m *SessionMutation) ClearTasks() { +func (m *QuestMutation) ClearTasks() { m.clearedtasks = true } // TasksCleared reports if the "tasks" edge to the Task entity was cleared. -func (m *SessionMutation) TasksCleared() bool { +func (m *QuestMutation) TasksCleared() bool { return m.clearedtasks } // RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs. -func (m *SessionMutation) RemoveTaskIDs(ids ...int) { +func (m *QuestMutation) RemoveTaskIDs(ids ...int) { if m.removedtasks == nil { m.removedtasks = make(map[int]struct{}) } @@ -2064,7 +2112,7 @@ func (m *SessionMutation) RemoveTaskIDs(ids ...int) { } // RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity. -func (m *SessionMutation) RemovedTasksIDs() (ids []int) { +func (m *QuestMutation) RemovedTasksIDs() (ids []int) { for id := range m.removedtasks { ids = append(ids, id) } @@ -2072,7 +2120,7 @@ func (m *SessionMutation) RemovedTasksIDs() (ids []int) { } // TasksIDs returns the "tasks" edge IDs in the mutation. -func (m *SessionMutation) TasksIDs() (ids []int) { +func (m *QuestMutation) TasksIDs() (ids []int) { for id := range m.tasks { ids = append(ids, id) } @@ -2080,21 +2128,60 @@ func (m *SessionMutation) TasksIDs() (ids []int) { } // ResetTasks resets all changes to the "tasks" edge. -func (m *SessionMutation) ResetTasks() { +func (m *QuestMutation) ResetTasks() { m.tasks = nil m.clearedtasks = false m.removedtasks = nil } -// Where appends a list predicates to the SessionMutation builder. -func (m *SessionMutation) Where(ps ...predicate.Session) { +// SetCreatorID sets the "creator" edge to the User entity by id. +func (m *QuestMutation) SetCreatorID(id int) { + m.creator = &id +} + +// ClearCreator clears the "creator" edge to the User entity. +func (m *QuestMutation) ClearCreator() { + m.clearedcreator = true +} + +// CreatorCleared reports if the "creator" edge to the User entity was cleared. +func (m *QuestMutation) CreatorCleared() bool { + return m.clearedcreator +} + +// CreatorID returns the "creator" edge ID in the mutation. +func (m *QuestMutation) CreatorID() (id int, exists bool) { + if m.creator != nil { + return *m.creator, true + } + return +} + +// CreatorIDs returns the "creator" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// CreatorID instead. It exists only for internal usage by the builders. +func (m *QuestMutation) CreatorIDs() (ids []int) { + if id := m.creator; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetCreator resets all changes to the "creator" edge. +func (m *QuestMutation) ResetCreator() { + m.creator = nil + m.clearedcreator = false +} + +// Where appends a list predicates to the QuestMutation builder. +func (m *QuestMutation) Where(ps ...predicate.Quest) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the SessionMutation builder. Using this method, +// WhereP appends storage-level predicates to the QuestMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SessionMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Session, len(ps)) +func (m *QuestMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Quest, len(ps)) for i := range ps { p[i] = ps[i] } @@ -2102,51 +2189,36 @@ func (m *SessionMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *SessionMutation) Op() Op { +func (m *QuestMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *SessionMutation) SetOp(op Op) { +func (m *QuestMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Session). -func (m *SessionMutation) Type() string { +// Type returns the node type of this mutation (Quest). +func (m *QuestMutation) 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 *SessionMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.name != nil { - fields = append(fields, session.FieldName) - } - if m.principal != nil { - fields = append(fields, session.FieldPrincipal) - } - if m.hostname != nil { - fields = append(fields, session.FieldHostname) - } - if m.identifier != nil { - fields = append(fields, session.FieldIdentifier) - } - if m.agent_identifier != nil { - fields = append(fields, session.FieldAgentIdentifier) - } - if m.host_identifier != nil { - fields = append(fields, session.FieldHostIdentifier) +func (m *QuestMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.created_at != nil { + fields = append(fields, quest.FieldCreatedAt) } - if m.host_primary_ip != nil { - fields = append(fields, session.FieldHostPrimaryIP) + if m.last_modified_at != nil { + fields = append(fields, quest.FieldLastModifiedAt) } - if m.host_platform != nil { - fields = append(fields, session.FieldHostPlatform) + if m.name != nil { + fields = append(fields, quest.FieldName) } - if m.last_seen_at != nil { - fields = append(fields, session.FieldLastSeenAt) + if m.parameters != nil { + fields = append(fields, quest.FieldParameters) } return fields } @@ -2154,26 +2226,16 @@ func (m *SessionMutation) 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 *SessionMutation) Field(name string) (ent.Value, bool) { +func (m *QuestMutation) Field(name string) (ent.Value, bool) { switch name { - case session.FieldName: + case quest.FieldCreatedAt: + return m.CreatedAt() + case quest.FieldLastModifiedAt: + return m.LastModifiedAt() + case quest.FieldName: return m.Name() - case session.FieldPrincipal: - return m.Principal() - case session.FieldHostname: - return m.Hostname() - case session.FieldIdentifier: - return m.Identifier() - case session.FieldAgentIdentifier: - return m.AgentIdentifier() - case session.FieldHostIdentifier: - return m.HostIdentifier() - case session.FieldHostPrimaryIP: - return m.HostPrimaryIP() - case session.FieldHostPlatform: - return m.HostPlatform() - case session.FieldLastSeenAt: - return m.LastSeenAt() + case quest.FieldParameters: + return m.Parameters() } return nil, false } @@ -2181,272 +2243,185 @@ func (m *SessionMutation) 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 *SessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *QuestMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case session.FieldName: + case quest.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case quest.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) + case quest.FieldName: return m.OldName(ctx) - case session.FieldPrincipal: - return m.OldPrincipal(ctx) - case session.FieldHostname: - return m.OldHostname(ctx) - case session.FieldIdentifier: - return m.OldIdentifier(ctx) - case session.FieldAgentIdentifier: - return m.OldAgentIdentifier(ctx) - case session.FieldHostIdentifier: - return m.OldHostIdentifier(ctx) - case session.FieldHostPrimaryIP: - return m.OldHostPrimaryIP(ctx) - case session.FieldHostPlatform: - return m.OldHostPlatform(ctx) - case session.FieldLastSeenAt: - return m.OldLastSeenAt(ctx) + case quest.FieldParameters: + return m.OldParameters(ctx) } - return nil, fmt.Errorf("unknown Session field %s", name) + return nil, fmt.Errorf("unknown Quest 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 *SessionMutation) SetField(name string, value ent.Value) error { +func (m *QuestMutation) SetField(name string, value ent.Value) error { switch name { - case session.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case session.FieldPrincipal: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPrincipal(v) - return nil - case session.FieldHostname: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHostname(v) - return nil - case session.FieldIdentifier: - v, ok := value.(string) + case quest.FieldCreatedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIdentifier(v) + m.SetCreatedAt(v) return nil - case session.FieldAgentIdentifier: - v, ok := value.(string) + case quest.FieldLastModifiedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAgentIdentifier(v) + m.SetLastModifiedAt(v) return nil - case session.FieldHostIdentifier: + case quest.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetHostIdentifier(v) + m.SetName(v) return nil - case session.FieldHostPrimaryIP: + case quest.FieldParameters: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetHostPrimaryIP(v) - return nil - case session.FieldHostPlatform: - v, ok := value.(session.HostPlatform) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHostPlatform(v) - return nil - case session.FieldLastSeenAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastSeenAt(v) + m.SetParameters(v) return nil } - return fmt.Errorf("unknown Session field %s", name) + return fmt.Errorf("unknown Quest field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *SessionMutation) AddedFields() []string { +func (m *QuestMutation) AddedFields() []string { return nil } // 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 *SessionMutation) AddedField(name string) (ent.Value, bool) { +func (m *QuestMutation) AddedField(name string) (ent.Value, bool) { 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 *SessionMutation) AddField(name string, value ent.Value) error { +func (m *QuestMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Session numeric field %s", name) + return fmt.Errorf("unknown Quest numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *SessionMutation) ClearedFields() []string { +func (m *QuestMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(session.FieldPrincipal) { - fields = append(fields, session.FieldPrincipal) - } - if m.FieldCleared(session.FieldHostname) { - fields = append(fields, session.FieldHostname) - } - if m.FieldCleared(session.FieldAgentIdentifier) { - fields = append(fields, session.FieldAgentIdentifier) - } - if m.FieldCleared(session.FieldHostIdentifier) { - fields = append(fields, session.FieldHostIdentifier) - } - if m.FieldCleared(session.FieldHostPrimaryIP) { - fields = append(fields, session.FieldHostPrimaryIP) - } - if m.FieldCleared(session.FieldLastSeenAt) { - fields = append(fields, session.FieldLastSeenAt) + if m.FieldCleared(quest.FieldParameters) { + fields = append(fields, quest.FieldParameters) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *SessionMutation) FieldCleared(name string) bool { +func (m *QuestMutation) 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 *SessionMutation) ClearField(name string) error { +func (m *QuestMutation) ClearField(name string) error { switch name { - case session.FieldPrincipal: - m.ClearPrincipal() - return nil - case session.FieldHostname: - m.ClearHostname() - return nil - case session.FieldAgentIdentifier: - m.ClearAgentIdentifier() - return nil - case session.FieldHostIdentifier: - m.ClearHostIdentifier() - return nil - case session.FieldHostPrimaryIP: - m.ClearHostPrimaryIP() - return nil - case session.FieldLastSeenAt: - m.ClearLastSeenAt() + case quest.FieldParameters: + m.ClearParameters() return nil } - return fmt.Errorf("unknown Session nullable field %s", name) + return fmt.Errorf("unknown Quest 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 *SessionMutation) ResetField(name string) error { +func (m *QuestMutation) ResetField(name string) error { switch name { - case session.FieldName: - m.ResetName() - return nil - case session.FieldPrincipal: - m.ResetPrincipal() - return nil - case session.FieldHostname: - m.ResetHostname() - return nil - case session.FieldIdentifier: - m.ResetIdentifier() - return nil - case session.FieldAgentIdentifier: - m.ResetAgentIdentifier() - return nil - case session.FieldHostIdentifier: - m.ResetHostIdentifier() + case quest.FieldCreatedAt: + m.ResetCreatedAt() return nil - case session.FieldHostPrimaryIP: - m.ResetHostPrimaryIP() + case quest.FieldLastModifiedAt: + m.ResetLastModifiedAt() return nil - case session.FieldHostPlatform: - m.ResetHostPlatform() + case quest.FieldName: + m.ResetName() return nil - case session.FieldLastSeenAt: - m.ResetLastSeenAt() + case quest.FieldParameters: + m.ResetParameters() return nil } - return fmt.Errorf("unknown Session field %s", name) + return fmt.Errorf("unknown Quest field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *SessionMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.tags != nil { - edges = append(edges, session.EdgeTags) +func (m *QuestMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.tome != nil { + edges = append(edges, quest.EdgeTome) + } + if m.bundle != nil { + edges = append(edges, quest.EdgeBundle) } if m.tasks != nil { - edges = append(edges, session.EdgeTasks) + edges = append(edges, quest.EdgeTasks) + } + if m.creator != nil { + edges = append(edges, quest.EdgeCreator) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *SessionMutation) AddedIDs(name string) []ent.Value { +func (m *QuestMutation) AddedIDs(name string) []ent.Value { switch name { - case session.EdgeTags: - ids := make([]ent.Value, 0, len(m.tags)) - for id := range m.tags { - ids = append(ids, id) + case quest.EdgeTome: + if id := m.tome; id != nil { + return []ent.Value{*id} } - return ids - case session.EdgeTasks: + case quest.EdgeBundle: + if id := m.bundle; id != nil { + return []ent.Value{*id} + } + case quest.EdgeTasks: ids := make([]ent.Value, 0, len(m.tasks)) for id := range m.tasks { ids = append(ids, id) } return ids + case quest.EdgeCreator: + if id := m.creator; id != nil { + return []ent.Value{*id} + } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *SessionMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - if m.removedtags != nil { - edges = append(edges, session.EdgeTags) - } +func (m *QuestMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) if m.removedtasks != nil { - edges = append(edges, session.EdgeTasks) + edges = append(edges, quest.EdgeTasks) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *SessionMutation) RemovedIDs(name string) []ent.Value { +func (m *QuestMutation) RemovedIDs(name string) []ent.Value { switch name { - case session.EdgeTags: - ids := make([]ent.Value, 0, len(m.removedtags)) - for id := range m.removedtags { - ids = append(ids, id) - } - return ids - case session.EdgeTasks: + case quest.EdgeTasks: ids := make([]ent.Value, 0, len(m.removedtasks)) for id := range m.removedtasks { ids = append(ids, id) @@ -2457,66 +2432,91 @@ func (m *SessionMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SessionMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedtags { - edges = append(edges, session.EdgeTags) +func (m *QuestMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedtome { + edges = append(edges, quest.EdgeTome) + } + if m.clearedbundle { + edges = append(edges, quest.EdgeBundle) } if m.clearedtasks { - edges = append(edges, session.EdgeTasks) + edges = append(edges, quest.EdgeTasks) + } + if m.clearedcreator { + edges = append(edges, quest.EdgeCreator) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *SessionMutation) EdgeCleared(name string) bool { +func (m *QuestMutation) EdgeCleared(name string) bool { switch name { - case session.EdgeTags: - return m.clearedtags - case session.EdgeTasks: + case quest.EdgeTome: + return m.clearedtome + case quest.EdgeBundle: + return m.clearedbundle + case quest.EdgeTasks: return m.clearedtasks + case quest.EdgeCreator: + return m.clearedcreator } 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 *SessionMutation) ClearEdge(name string) error { +func (m *QuestMutation) ClearEdge(name string) error { switch name { + case quest.EdgeTome: + m.ClearTome() + return nil + case quest.EdgeBundle: + m.ClearBundle() + return nil + case quest.EdgeCreator: + m.ClearCreator() + return nil } - return fmt.Errorf("unknown Session unique edge %s", name) + return fmt.Errorf("unknown Quest 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 *SessionMutation) ResetEdge(name string) error { +func (m *QuestMutation) ResetEdge(name string) error { switch name { - case session.EdgeTags: - m.ResetTags() + case quest.EdgeTome: + m.ResetTome() return nil - case session.EdgeTasks: + case quest.EdgeBundle: + m.ResetBundle() + return nil + case quest.EdgeTasks: m.ResetTasks() return nil + case quest.EdgeCreator: + m.ResetCreator() + return nil } - return fmt.Errorf("unknown Session edge %s", name) + return fmt.Errorf("unknown Quest edge %s", name) } // TagMutation represents an operation that mutates the Tag nodes in the graph. type TagMutation struct { config - op Op - typ string - id *int - name *string - kind *tag.Kind - clearedFields map[string]struct{} - sessions map[int]struct{} - removedsessions map[int]struct{} - clearedsessions bool - done bool - oldValue func(context.Context) (*Tag, error) - predicates []predicate.Tag + op Op + typ string + id *int + name *string + kind *tag.Kind + clearedFields map[string]struct{} + beacons map[int]struct{} + removedbeacons map[int]struct{} + clearedbeacons bool + done bool + oldValue func(context.Context) (*Tag, error) + predicates []predicate.Tag } var _ ent.Mutation = (*TagMutation)(nil) @@ -2689,58 +2689,58 @@ func (m *TagMutation) ResetKind() { m.kind = nil } -// AddSessionIDs adds the "sessions" edge to the Session entity by ids. -func (m *TagMutation) AddSessionIDs(ids ...int) { - if m.sessions == nil { - m.sessions = make(map[int]struct{}) +// AddBeaconIDs adds the "beacons" edge to the Beacon entity by ids. +func (m *TagMutation) AddBeaconIDs(ids ...int) { + if m.beacons == nil { + m.beacons = make(map[int]struct{}) } for i := range ids { - m.sessions[ids[i]] = struct{}{} + m.beacons[ids[i]] = struct{}{} } } -// ClearSessions clears the "sessions" edge to the Session entity. -func (m *TagMutation) ClearSessions() { - m.clearedsessions = true +// ClearBeacons clears the "beacons" edge to the Beacon entity. +func (m *TagMutation) ClearBeacons() { + m.clearedbeacons = true } -// SessionsCleared reports if the "sessions" edge to the Session entity was cleared. -func (m *TagMutation) SessionsCleared() bool { - return m.clearedsessions +// BeaconsCleared reports if the "beacons" edge to the Beacon entity was cleared. +func (m *TagMutation) BeaconsCleared() bool { + return m.clearedbeacons } -// RemoveSessionIDs removes the "sessions" edge to the Session entity by IDs. -func (m *TagMutation) RemoveSessionIDs(ids ...int) { - if m.removedsessions == nil { - m.removedsessions = make(map[int]struct{}) +// RemoveBeaconIDs removes the "beacons" edge to the Beacon entity by IDs. +func (m *TagMutation) RemoveBeaconIDs(ids ...int) { + if m.removedbeacons == nil { + m.removedbeacons = make(map[int]struct{}) } for i := range ids { - delete(m.sessions, ids[i]) - m.removedsessions[ids[i]] = struct{}{} + delete(m.beacons, ids[i]) + m.removedbeacons[ids[i]] = struct{}{} } } -// RemovedSessions returns the removed IDs of the "sessions" edge to the Session entity. -func (m *TagMutation) RemovedSessionsIDs() (ids []int) { - for id := range m.removedsessions { +// RemovedBeacons returns the removed IDs of the "beacons" edge to the Beacon entity. +func (m *TagMutation) RemovedBeaconsIDs() (ids []int) { + for id := range m.removedbeacons { ids = append(ids, id) } return } -// SessionsIDs returns the "sessions" edge IDs in the mutation. -func (m *TagMutation) SessionsIDs() (ids []int) { - for id := range m.sessions { +// BeaconsIDs returns the "beacons" edge IDs in the mutation. +func (m *TagMutation) BeaconsIDs() (ids []int) { + for id := range m.beacons { ids = append(ids, id) } return } -// ResetSessions resets all changes to the "sessions" edge. -func (m *TagMutation) ResetSessions() { - m.sessions = nil - m.clearedsessions = false - m.removedsessions = nil +// ResetBeacons resets all changes to the "beacons" edge. +func (m *TagMutation) ResetBeacons() { + m.beacons = nil + m.clearedbeacons = false + m.removedbeacons = nil } // Where appends a list predicates to the TagMutation builder. @@ -2894,8 +2894,8 @@ func (m *TagMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TagMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.sessions != nil { - edges = append(edges, tag.EdgeSessions) + if m.beacons != nil { + edges = append(edges, tag.EdgeBeacons) } return edges } @@ -2904,9 +2904,9 @@ func (m *TagMutation) AddedEdges() []string { // name in this mutation. func (m *TagMutation) AddedIDs(name string) []ent.Value { switch name { - case tag.EdgeSessions: - ids := make([]ent.Value, 0, len(m.sessions)) - for id := range m.sessions { + case tag.EdgeBeacons: + ids := make([]ent.Value, 0, len(m.beacons)) + for id := range m.beacons { ids = append(ids, id) } return ids @@ -2917,8 +2917,8 @@ func (m *TagMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *TagMutation) RemovedEdges() []string { edges := make([]string, 0, 1) - if m.removedsessions != nil { - edges = append(edges, tag.EdgeSessions) + if m.removedbeacons != nil { + edges = append(edges, tag.EdgeBeacons) } return edges } @@ -2927,9 +2927,9 @@ func (m *TagMutation) RemovedEdges() []string { // the given name in this mutation. func (m *TagMutation) RemovedIDs(name string) []ent.Value { switch name { - case tag.EdgeSessions: - ids := make([]ent.Value, 0, len(m.removedsessions)) - for id := range m.removedsessions { + case tag.EdgeBeacons: + ids := make([]ent.Value, 0, len(m.removedbeacons)) + for id := range m.removedbeacons { ids = append(ids, id) } return ids @@ -2940,8 +2940,8 @@ func (m *TagMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TagMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedsessions { - edges = append(edges, tag.EdgeSessions) + if m.clearedbeacons { + edges = append(edges, tag.EdgeBeacons) } return edges } @@ -2950,8 +2950,8 @@ func (m *TagMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *TagMutation) EdgeCleared(name string) bool { switch name { - case tag.EdgeSessions: - return m.clearedsessions + case tag.EdgeBeacons: + return m.clearedbeacons } return false } @@ -2968,8 +2968,8 @@ func (m *TagMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *TagMutation) ResetEdge(name string) error { switch name { - case tag.EdgeSessions: - m.ResetSessions() + case tag.EdgeBeacons: + m.ResetBeacons() return nil } return fmt.Errorf("unknown Tag edge %s", name) @@ -2989,10 +2989,10 @@ type TaskMutation struct { output *string error *string clearedFields map[string]struct{} - job *int - clearedjob bool - session *int - clearedsession bool + quest *int + clearedquest bool + beacon *int + clearedbeacon bool done bool oldValue func(context.Context) (*Task, error) predicates []predicate.Task @@ -3413,82 +3413,82 @@ func (m *TaskMutation) ResetError() { delete(m.clearedFields, task.FieldError) } -// SetJobID sets the "job" edge to the Job entity by id. -func (m *TaskMutation) SetJobID(id int) { - m.job = &id +// SetQuestID sets the "quest" edge to the Quest entity by id. +func (m *TaskMutation) SetQuestID(id int) { + m.quest = &id } -// ClearJob clears the "job" edge to the Job entity. -func (m *TaskMutation) ClearJob() { - m.clearedjob = true +// ClearQuest clears the "quest" edge to the Quest entity. +func (m *TaskMutation) ClearQuest() { + m.clearedquest = true } -// JobCleared reports if the "job" edge to the Job entity was cleared. -func (m *TaskMutation) JobCleared() bool { - return m.clearedjob +// QuestCleared reports if the "quest" edge to the Quest entity was cleared. +func (m *TaskMutation) QuestCleared() bool { + return m.clearedquest } -// JobID returns the "job" edge ID in the mutation. -func (m *TaskMutation) JobID() (id int, exists bool) { - if m.job != nil { - return *m.job, true +// QuestID returns the "quest" edge ID in the mutation. +func (m *TaskMutation) QuestID() (id int, exists bool) { + if m.quest != nil { + return *m.quest, true } return } -// JobIDs returns the "job" edge IDs in the mutation. +// QuestIDs returns the "quest" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// JobID instead. It exists only for internal usage by the builders. -func (m *TaskMutation) JobIDs() (ids []int) { - if id := m.job; id != nil { +// QuestID instead. It exists only for internal usage by the builders. +func (m *TaskMutation) QuestIDs() (ids []int) { + if id := m.quest; id != nil { ids = append(ids, *id) } return } -// ResetJob resets all changes to the "job" edge. -func (m *TaskMutation) ResetJob() { - m.job = nil - m.clearedjob = false +// ResetQuest resets all changes to the "quest" edge. +func (m *TaskMutation) ResetQuest() { + m.quest = nil + m.clearedquest = false } -// SetSessionID sets the "session" edge to the Session entity by id. -func (m *TaskMutation) SetSessionID(id int) { - m.session = &id +// SetBeaconID sets the "beacon" edge to the Beacon entity by id. +func (m *TaskMutation) SetBeaconID(id int) { + m.beacon = &id } -// ClearSession clears the "session" edge to the Session entity. -func (m *TaskMutation) ClearSession() { - m.clearedsession = true +// ClearBeacon clears the "beacon" edge to the Beacon entity. +func (m *TaskMutation) ClearBeacon() { + m.clearedbeacon = true } -// SessionCleared reports if the "session" edge to the Session entity was cleared. -func (m *TaskMutation) SessionCleared() bool { - return m.clearedsession +// BeaconCleared reports if the "beacon" edge to the Beacon entity was cleared. +func (m *TaskMutation) BeaconCleared() bool { + return m.clearedbeacon } -// SessionID returns the "session" edge ID in the mutation. -func (m *TaskMutation) SessionID() (id int, exists bool) { - if m.session != nil { - return *m.session, true +// BeaconID returns the "beacon" edge ID in the mutation. +func (m *TaskMutation) BeaconID() (id int, exists bool) { + if m.beacon != nil { + return *m.beacon, true } return } -// SessionIDs returns the "session" edge IDs in the mutation. +// BeaconIDs returns the "beacon" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// SessionID instead. It exists only for internal usage by the builders. -func (m *TaskMutation) SessionIDs() (ids []int) { - if id := m.session; id != nil { +// BeaconID instead. It exists only for internal usage by the builders. +func (m *TaskMutation) BeaconIDs() (ids []int) { + if id := m.beacon; id != nil { ids = append(ids, *id) } return } -// ResetSession resets all changes to the "session" edge. -func (m *TaskMutation) ResetSession() { - m.session = nil - m.clearedsession = false +// ResetBeacon resets all changes to the "beacon" edge. +func (m *TaskMutation) ResetBeacon() { + m.beacon = nil + m.clearedbeacon = false } // Where appends a list predicates to the TaskMutation builder. @@ -3760,11 +3760,11 @@ 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, 2) - if m.job != nil { - edges = append(edges, task.EdgeJob) + if m.quest != nil { + edges = append(edges, task.EdgeQuest) } - if m.session != nil { - edges = append(edges, task.EdgeSession) + if m.beacon != nil { + edges = append(edges, task.EdgeBeacon) } return edges } @@ -3773,12 +3773,12 @@ func (m *TaskMutation) AddedEdges() []string { // name in this mutation. func (m *TaskMutation) AddedIDs(name string) []ent.Value { switch name { - case task.EdgeJob: - if id := m.job; id != nil { + case task.EdgeQuest: + if id := m.quest; id != nil { return []ent.Value{*id} } - case task.EdgeSession: - if id := m.session; id != nil { + case task.EdgeBeacon: + if id := m.beacon; id != nil { return []ent.Value{*id} } } @@ -3800,11 +3800,11 @@ 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, 2) - if m.clearedjob { - edges = append(edges, task.EdgeJob) + if m.clearedquest { + edges = append(edges, task.EdgeQuest) } - if m.clearedsession { - edges = append(edges, task.EdgeSession) + if m.clearedbeacon { + edges = append(edges, task.EdgeBeacon) } return edges } @@ -3813,10 +3813,10 @@ func (m *TaskMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *TaskMutation) EdgeCleared(name string) bool { switch name { - case task.EdgeJob: - return m.clearedjob - case task.EdgeSession: - return m.clearedsession + case task.EdgeQuest: + return m.clearedquest + case task.EdgeBeacon: + return m.clearedbeacon } return false } @@ -3825,11 +3825,11 @@ func (m *TaskMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *TaskMutation) ClearEdge(name string) error { switch name { - case task.EdgeJob: - m.ClearJob() + case task.EdgeQuest: + m.ClearQuest() return nil - case task.EdgeSession: - m.ClearSession() + case task.EdgeBeacon: + m.ClearBeacon() return nil } return fmt.Errorf("unknown Task unique edge %s", name) @@ -3839,11 +3839,11 @@ func (m *TaskMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *TaskMutation) ResetEdge(name string) error { switch name { - case task.EdgeJob: - m.ResetJob() + case task.EdgeQuest: + m.ResetQuest() return nil - case task.EdgeSession: - m.ResetSession() + case task.EdgeBeacon: + m.ResetBeacon() return nil } return fmt.Errorf("unknown Task edge %s", name) diff --git a/tavern/ent/predicate/predicate.go b/tavern/ent/predicate/predicate.go index f096d30cf..7b03cf3ff 100644 --- a/tavern/ent/predicate/predicate.go +++ b/tavern/ent/predicate/predicate.go @@ -6,14 +6,14 @@ import ( "entgo.io/ent/dialect/sql" ) +// Beacon is the predicate function for beacon builders. +type Beacon func(*sql.Selector) + // File is the predicate function for file builders. type File func(*sql.Selector) -// Job is the predicate function for job builders. -type Job func(*sql.Selector) - -// Session is the predicate function for session builders. -type Session func(*sql.Selector) +// Quest is the predicate function for quest builders. +type Quest func(*sql.Selector) // Tag is the predicate function for tag builders. type Tag func(*sql.Selector) diff --git a/tavern/ent/privacy/privacy.go b/tavern/ent/privacy/privacy.go index e173f4be8..6a48a96ca 100644 --- a/tavern/ent/privacy/privacy.go +++ b/tavern/ent/privacy/privacy.go @@ -149,76 +149,76 @@ func DenyMutationOperationRule(op ent.Op) MutationRule { return OnMutationOperation(rule, op) } -// The FileQueryRuleFunc type is an adapter to allow the use of ordinary +// The BeaconQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. -type FileQueryRuleFunc func(context.Context, *ent.FileQuery) error +type BeaconQueryRuleFunc func(context.Context, *ent.BeaconQuery) error // EvalQuery return f(ctx, q). -func (f FileQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.FileQuery); ok { +func (f BeaconQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.BeaconQuery); ok { return f(ctx, q) } - return Denyf("ent/privacy: unexpected query type %T, expect *ent.FileQuery", q) + return Denyf("ent/privacy: unexpected query type %T, expect *ent.BeaconQuery", q) } -// The FileMutationRuleFunc type is an adapter to allow the use of ordinary +// The BeaconMutationRuleFunc type is an adapter to allow the use of ordinary // functions as a mutation rule. -type FileMutationRuleFunc func(context.Context, *ent.FileMutation) error +type BeaconMutationRuleFunc func(context.Context, *ent.BeaconMutation) error // EvalMutation calls f(ctx, m). -func (f FileMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { - if m, ok := m.(*ent.FileMutation); ok { +func (f BeaconMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.BeaconMutation); ok { return f(ctx, m) } - return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.FileMutation", m) + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BeaconMutation", m) } -// The JobQueryRuleFunc type is an adapter to allow the use of ordinary +// The FileQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. -type JobQueryRuleFunc func(context.Context, *ent.JobQuery) error +type FileQueryRuleFunc func(context.Context, *ent.FileQuery) error // EvalQuery return f(ctx, q). -func (f JobQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.JobQuery); ok { +func (f FileQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.FileQuery); ok { return f(ctx, q) } - return Denyf("ent/privacy: unexpected query type %T, expect *ent.JobQuery", q) + return Denyf("ent/privacy: unexpected query type %T, expect *ent.FileQuery", q) } -// The JobMutationRuleFunc type is an adapter to allow the use of ordinary +// The FileMutationRuleFunc type is an adapter to allow the use of ordinary // functions as a mutation rule. -type JobMutationRuleFunc func(context.Context, *ent.JobMutation) error +type FileMutationRuleFunc func(context.Context, *ent.FileMutation) error // EvalMutation calls f(ctx, m). -func (f JobMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { - if m, ok := m.(*ent.JobMutation); ok { +func (f FileMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.FileMutation); ok { return f(ctx, m) } - return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.JobMutation", m) + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.FileMutation", m) } -// The SessionQueryRuleFunc type is an adapter to allow the use of ordinary +// The QuestQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. -type SessionQueryRuleFunc func(context.Context, *ent.SessionQuery) error +type QuestQueryRuleFunc func(context.Context, *ent.QuestQuery) error // EvalQuery return f(ctx, q). -func (f SessionQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.SessionQuery); ok { +func (f QuestQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.QuestQuery); ok { return f(ctx, q) } - return Denyf("ent/privacy: unexpected query type %T, expect *ent.SessionQuery", q) + return Denyf("ent/privacy: unexpected query type %T, expect *ent.QuestQuery", q) } -// The SessionMutationRuleFunc type is an adapter to allow the use of ordinary +// The QuestMutationRuleFunc type is an adapter to allow the use of ordinary // functions as a mutation rule. -type SessionMutationRuleFunc func(context.Context, *ent.SessionMutation) error +type QuestMutationRuleFunc func(context.Context, *ent.QuestMutation) error // EvalMutation calls f(ctx, m). -func (f SessionMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { - if m, ok := m.(*ent.SessionMutation); ok { +func (f QuestMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.QuestMutation); ok { return f(ctx, m) } - return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.SessionMutation", m) + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.QuestMutation", m) } // The TagQueryRuleFunc type is an adapter to allow the use of ordinary diff --git a/tavern/ent/job.go b/tavern/ent/quest.go similarity index 56% rename from tavern/ent/job.go rename to tavern/ent/quest.go index 5bd0f9e4f..f3946075b 100644 --- a/tavern/ent/job.go +++ b/tavern/ent/quest.go @@ -9,13 +9,13 @@ import ( "entgo.io/ent/dialect/sql" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/tome" "github.com/kcarretto/realm/tavern/ent/user" ) -// Job is the model entity for the Job schema. -type Job struct { +// Quest is the model entity for the Quest schema. +type Quest struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` @@ -23,27 +23,27 @@ type Job struct { CreatedAt time.Time `json:"created_at,omitempty"` // Timestamp of when this ent was last updated LastModifiedAt time.Time `json:"last_modified_at,omitempty"` - // Name of the job + // Name of the quest Name string `json:"name,omitempty"` - // Value of parameters that were specified for the job (as a JSON string). + // Value of parameters that were specified for the quest (as a JSON string). Parameters string `json:"parameters,omitempty"` // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the JobQuery when eager-loading is set. - Edges JobEdges `json:"edges"` - job_tome *int - job_bundle *int - job_creator *int + // The values are being populated by the QuestQuery when eager-loading is set. + Edges QuestEdges `json:"edges"` + quest_tome *int + quest_bundle *int + quest_creator *int } -// JobEdges holds the relations/edges for other nodes in the graph. -type JobEdges struct { - // Tome that this job will be executing +// QuestEdges holds the relations/edges for other nodes in the graph. +type QuestEdges struct { + // Tome that this quest will be executing Tome *Tome `json:"tome,omitempty"` // Bundle file that the executing tome depends on (if any) Bundle *File `json:"bundle,omitempty"` // Tasks tracking the status and output of individual tome execution on targets Tasks []*Task `json:"tasks,omitempty"` - // User that created the job if available. + // User that created the quest if available. Creator *User `json:"creator,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. @@ -56,7 +56,7 @@ type JobEdges struct { // TomeOrErr returns the Tome value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e JobEdges) TomeOrErr() (*Tome, error) { +func (e QuestEdges) TomeOrErr() (*Tome, error) { if e.loadedTypes[0] { if e.Tome == nil { // Edge was loaded but was not found. @@ -69,7 +69,7 @@ func (e JobEdges) TomeOrErr() (*Tome, error) { // BundleOrErr returns the Bundle value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e JobEdges) BundleOrErr() (*File, error) { +func (e QuestEdges) BundleOrErr() (*File, error) { if e.loadedTypes[1] { if e.Bundle == nil { // Edge was loaded but was not found. @@ -82,7 +82,7 @@ func (e JobEdges) BundleOrErr() (*File, error) { // TasksOrErr returns the Tasks value or an error if the edge // was not loaded in eager-loading. -func (e JobEdges) TasksOrErr() ([]*Task, error) { +func (e QuestEdges) TasksOrErr() ([]*Task, error) { if e.loadedTypes[2] { return e.Tasks, nil } @@ -91,7 +91,7 @@ func (e JobEdges) TasksOrErr() ([]*Task, error) { // CreatorOrErr returns the Creator value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e JobEdges) CreatorOrErr() (*User, error) { +func (e QuestEdges) CreatorOrErr() (*User, error) { if e.loadedTypes[3] { if e.Creator == nil { // Edge was loaded but was not found. @@ -103,174 +103,174 @@ func (e JobEdges) CreatorOrErr() (*User, error) { } // scanValues returns the types for scanning values from sql.Rows. -func (*Job) scanValues(columns []string) ([]any, error) { +func (*Quest) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case job.FieldID: + case quest.FieldID: values[i] = new(sql.NullInt64) - case job.FieldName, job.FieldParameters: + case quest.FieldName, quest.FieldParameters: values[i] = new(sql.NullString) - case job.FieldCreatedAt, job.FieldLastModifiedAt: + case quest.FieldCreatedAt, quest.FieldLastModifiedAt: values[i] = new(sql.NullTime) - case job.ForeignKeys[0]: // job_tome + case quest.ForeignKeys[0]: // quest_tome values[i] = new(sql.NullInt64) - case job.ForeignKeys[1]: // job_bundle + case quest.ForeignKeys[1]: // quest_bundle values[i] = new(sql.NullInt64) - case job.ForeignKeys[2]: // job_creator + case quest.ForeignKeys[2]: // quest_creator values[i] = new(sql.NullInt64) default: - return nil, fmt.Errorf("unexpected column %q for type Job", columns[i]) + return nil, fmt.Errorf("unexpected column %q for type Quest", columns[i]) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Job fields. -func (j *Job) assignValues(columns []string, values []any) error { +// to the Quest fields. +func (q *Quest) 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 job.FieldID: + case quest.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - j.ID = int(value.Int64) - case job.FieldCreatedAt: + q.ID = int(value.Int64) + case quest.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 { - j.CreatedAt = value.Time + q.CreatedAt = value.Time } - case job.FieldLastModifiedAt: + case quest.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 { - j.LastModifiedAt = value.Time + q.LastModifiedAt = value.Time } - case job.FieldName: + case quest.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - j.Name = value.String + q.Name = value.String } - case job.FieldParameters: + case quest.FieldParameters: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field parameters", values[i]) } else if value.Valid { - j.Parameters = value.String + q.Parameters = value.String } - case job.ForeignKeys[0]: + case quest.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field job_tome", value) + return fmt.Errorf("unexpected type %T for edge-field quest_tome", value) } else if value.Valid { - j.job_tome = new(int) - *j.job_tome = int(value.Int64) + q.quest_tome = new(int) + *q.quest_tome = int(value.Int64) } - case job.ForeignKeys[1]: + case quest.ForeignKeys[1]: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field job_bundle", value) + return fmt.Errorf("unexpected type %T for edge-field quest_bundle", value) } else if value.Valid { - j.job_bundle = new(int) - *j.job_bundle = int(value.Int64) + q.quest_bundle = new(int) + *q.quest_bundle = int(value.Int64) } - case job.ForeignKeys[2]: + case quest.ForeignKeys[2]: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field job_creator", value) + return fmt.Errorf("unexpected type %T for edge-field quest_creator", value) } else if value.Valid { - j.job_creator = new(int) - *j.job_creator = int(value.Int64) + q.quest_creator = new(int) + *q.quest_creator = int(value.Int64) } } } return nil } -// QueryTome queries the "tome" edge of the Job entity. -func (j *Job) QueryTome() *TomeQuery { - return NewJobClient(j.config).QueryTome(j) +// QueryTome queries the "tome" edge of the Quest entity. +func (q *Quest) QueryTome() *TomeQuery { + return NewQuestClient(q.config).QueryTome(q) } -// QueryBundle queries the "bundle" edge of the Job entity. -func (j *Job) QueryBundle() *FileQuery { - return NewJobClient(j.config).QueryBundle(j) +// QueryBundle queries the "bundle" edge of the Quest entity. +func (q *Quest) QueryBundle() *FileQuery { + return NewQuestClient(q.config).QueryBundle(q) } -// QueryTasks queries the "tasks" edge of the Job entity. -func (j *Job) QueryTasks() *TaskQuery { - return NewJobClient(j.config).QueryTasks(j) +// QueryTasks queries the "tasks" edge of the Quest entity. +func (q *Quest) QueryTasks() *TaskQuery { + return NewQuestClient(q.config).QueryTasks(q) } -// QueryCreator queries the "creator" edge of the Job entity. -func (j *Job) QueryCreator() *UserQuery { - return NewJobClient(j.config).QueryCreator(j) +// QueryCreator queries the "creator" edge of the Quest entity. +func (q *Quest) QueryCreator() *UserQuery { + return NewQuestClient(q.config).QueryCreator(q) } -// Update returns a builder for updating this Job. -// Note that you need to call Job.Unwrap() before calling this method if this Job +// Update returns a builder for updating this Quest. +// Note that you need to call Quest.Unwrap() before calling this method if this Quest // was returned from a transaction, and the transaction was committed or rolled back. -func (j *Job) Update() *JobUpdateOne { - return NewJobClient(j.config).UpdateOne(j) +func (q *Quest) Update() *QuestUpdateOne { + return NewQuestClient(q.config).UpdateOne(q) } -// Unwrap unwraps the Job entity that was returned from a transaction after it was closed, +// Unwrap unwraps the Quest 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 (j *Job) Unwrap() *Job { - _tx, ok := j.config.driver.(*txDriver) +func (q *Quest) Unwrap() *Quest { + _tx, ok := q.config.driver.(*txDriver) if !ok { - panic("ent: Job is not a transactional entity") + panic("ent: Quest is not a transactional entity") } - j.config.driver = _tx.drv - return j + q.config.driver = _tx.drv + return q } // String implements the fmt.Stringer. -func (j *Job) String() string { +func (q *Quest) String() string { var builder strings.Builder - builder.WriteString("Job(") - builder.WriteString(fmt.Sprintf("id=%v, ", j.ID)) + builder.WriteString("Quest(") + builder.WriteString(fmt.Sprintf("id=%v, ", q.ID)) builder.WriteString("created_at=") - builder.WriteString(j.CreatedAt.Format(time.ANSIC)) + builder.WriteString(q.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("last_modified_at=") - builder.WriteString(j.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(q.LastModifiedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") - builder.WriteString(j.Name) + builder.WriteString(q.Name) builder.WriteString(", ") builder.WriteString("parameters=") - builder.WriteString(j.Parameters) + builder.WriteString(q.Parameters) builder.WriteByte(')') return builder.String() } // NamedTasks returns the Tasks named value or an error if the edge was not // loaded in eager-loading with this name. -func (j *Job) NamedTasks(name string) ([]*Task, error) { - if j.Edges.namedTasks == nil { +func (q *Quest) NamedTasks(name string) ([]*Task, error) { + if q.Edges.namedTasks == nil { return nil, &NotLoadedError{edge: name} } - nodes, ok := j.Edges.namedTasks[name] + nodes, ok := q.Edges.namedTasks[name] if !ok { return nil, &NotLoadedError{edge: name} } return nodes, nil } -func (j *Job) appendNamedTasks(name string, edges ...*Task) { - if j.Edges.namedTasks == nil { - j.Edges.namedTasks = make(map[string][]*Task) +func (q *Quest) appendNamedTasks(name string, edges ...*Task) { + if q.Edges.namedTasks == nil { + q.Edges.namedTasks = make(map[string][]*Task) } if len(edges) == 0 { - j.Edges.namedTasks[name] = []*Task{} + q.Edges.namedTasks[name] = []*Task{} } else { - j.Edges.namedTasks[name] = append(j.Edges.namedTasks[name], edges...) + q.Edges.namedTasks[name] = append(q.Edges.namedTasks[name], edges...) } } -// Jobs is a parsable slice of Job. -type Jobs []*Job +// Quests is a parsable slice of Quest. +type Quests []*Quest diff --git a/tavern/ent/job/job.go b/tavern/ent/quest/quest.go similarity index 87% rename from tavern/ent/job/job.go rename to tavern/ent/quest/quest.go index 7958c2041..763b13560 100644 --- a/tavern/ent/job/job.go +++ b/tavern/ent/quest/quest.go @@ -1,14 +1,14 @@ // Code generated by ent, DO NOT EDIT. -package job +package quest import ( "time" ) const ( - // Label holds the string label denoting the job type in the database. - Label = "job" + // Label holds the string label denoting the quest type in the database. + Label = "quest" // 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. @@ -27,39 +27,39 @@ const ( EdgeTasks = "tasks" // EdgeCreator holds the string denoting the creator edge name in mutations. EdgeCreator = "creator" - // Table holds the table name of the job in the database. - Table = "jobs" + // Table holds the table name of the quest in the database. + Table = "quests" // TomeTable is the table that holds the tome relation/edge. - TomeTable = "jobs" + TomeTable = "quests" // TomeInverseTable is the table name for the Tome entity. // It exists in this package in order to avoid circular dependency with the "tome" package. TomeInverseTable = "tomes" // TomeColumn is the table column denoting the tome relation/edge. - TomeColumn = "job_tome" + TomeColumn = "quest_tome" // BundleTable is the table that holds the bundle relation/edge. - BundleTable = "jobs" + BundleTable = "quests" // BundleInverseTable is the table name for the File entity. // It exists in this package in order to avoid circular dependency with the "file" package. BundleInverseTable = "files" // BundleColumn is the table column denoting the bundle relation/edge. - BundleColumn = "job_bundle" + BundleColumn = "quest_bundle" // TasksTable is the table that holds the tasks relation/edge. TasksTable = "tasks" // TasksInverseTable is the table name for the Task entity. // It exists in this package in order to avoid circular dependency with the "task" package. TasksInverseTable = "tasks" // TasksColumn is the table column denoting the tasks relation/edge. - TasksColumn = "job_tasks" + TasksColumn = "quest_tasks" // CreatorTable is the table that holds the creator relation/edge. - CreatorTable = "jobs" + CreatorTable = "quests" // CreatorInverseTable is the table name for the User entity. // It exists in this package in order to avoid circular dependency with the "user" package. CreatorInverseTable = "users" // CreatorColumn is the table column denoting the creator relation/edge. - CreatorColumn = "job_creator" + CreatorColumn = "quest_creator" ) -// Columns holds all SQL columns for job fields. +// Columns holds all SQL columns for quest fields. var Columns = []string{ FieldID, FieldCreatedAt, @@ -68,12 +68,12 @@ var Columns = []string{ FieldParameters, } -// ForeignKeys holds the SQL foreign-keys that are owned by the "jobs" +// ForeignKeys holds the SQL foreign-keys that are owned by the "quests" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ - "job_tome", - "job_bundle", - "job_creator", + "quest_tome", + "quest_bundle", + "quest_creator", } // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/tavern/ent/job/where.go b/tavern/ent/quest/where.go similarity index 51% rename from tavern/ent/job/where.go rename to tavern/ent/quest/where.go index cc1647223..5bbf0bba5 100644 --- a/tavern/ent/job/where.go +++ b/tavern/ent/quest/where.go @@ -1,6 +1,6 @@ // Code generated by ent, DO NOT EDIT. -package job +package quest import ( "time" @@ -11,293 +11,293 @@ import ( ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldID, id)) +func ID(id int) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldID, id)) +func IDEQ(id int) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Job { - return predicate.Job(sql.FieldNEQ(FieldID, id)) +func IDNEQ(id int) predicate.Quest { + return predicate.Quest(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Job { - return predicate.Job(sql.FieldIn(FieldID, ids...)) +func IDIn(ids ...int) predicate.Quest { + return predicate.Quest(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Job { - return predicate.Job(sql.FieldNotIn(FieldID, ids...)) +func IDNotIn(ids ...int) predicate.Quest { + return predicate.Quest(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Job { - return predicate.Job(sql.FieldGT(FieldID, id)) +func IDGT(id int) predicate.Quest { + return predicate.Quest(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Job { - return predicate.Job(sql.FieldGTE(FieldID, id)) +func IDGTE(id int) predicate.Quest { + return predicate.Quest(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Job { - return predicate.Job(sql.FieldLT(FieldID, id)) +func IDLT(id int) predicate.Quest { + return predicate.Quest(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Job { - return predicate.Job(sql.FieldLTE(FieldID, id)) +func IDLTE(id int) predicate.Quest { + return predicate.Quest(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.Job { - return predicate.Job(sql.FieldEQ(FieldCreatedAt, v)) +func CreatedAt(v time.Time) predicate.Quest { + return predicate.Quest(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.Job { - return predicate.Job(sql.FieldEQ(FieldLastModifiedAt, v)) +func LastModifiedAt(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldLastModifiedAt, v)) } // Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldName, v)) +func Name(v string) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldName, v)) } // Parameters applies equality check predicate on the "parameters" field. It's identical to ParametersEQ. -func Parameters(v string) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldParameters, v)) +func Parameters(v string) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldParameters, v)) } // CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldCreatedAt, v)) +func CreatedAtEQ(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldCreatedAt, v)) } // CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.Job { - return predicate.Job(sql.FieldNEQ(FieldCreatedAt, v)) +func CreatedAtNEQ(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldNEQ(FieldCreatedAt, v)) } // CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.Job { - return predicate.Job(sql.FieldIn(FieldCreatedAt, vs...)) +func CreatedAtIn(vs ...time.Time) predicate.Quest { + return predicate.Quest(sql.FieldIn(FieldCreatedAt, vs...)) } // CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.Job { - return predicate.Job(sql.FieldNotIn(FieldCreatedAt, vs...)) +func CreatedAtNotIn(vs ...time.Time) predicate.Quest { + return predicate.Quest(sql.FieldNotIn(FieldCreatedAt, vs...)) } // CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.Job { - return predicate.Job(sql.FieldGT(FieldCreatedAt, v)) +func CreatedAtGT(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldGT(FieldCreatedAt, v)) } // CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.Job { - return predicate.Job(sql.FieldGTE(FieldCreatedAt, v)) +func CreatedAtGTE(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldGTE(FieldCreatedAt, v)) } // CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.Job { - return predicate.Job(sql.FieldLT(FieldCreatedAt, v)) +func CreatedAtLT(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldLT(FieldCreatedAt, v)) } // CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.Job { - return predicate.Job(sql.FieldLTE(FieldCreatedAt, v)) +func CreatedAtLTE(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldLTE(FieldCreatedAt, v)) } // LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. -func LastModifiedAtEQ(v time.Time) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldLastModifiedAt, v)) +func LastModifiedAtEQ(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldLastModifiedAt, v)) } // LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. -func LastModifiedAtNEQ(v time.Time) predicate.Job { - return predicate.Job(sql.FieldNEQ(FieldLastModifiedAt, v)) +func LastModifiedAtNEQ(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldNEQ(FieldLastModifiedAt, v)) } // LastModifiedAtIn applies the In predicate on the "last_modified_at" field. -func LastModifiedAtIn(vs ...time.Time) predicate.Job { - return predicate.Job(sql.FieldIn(FieldLastModifiedAt, vs...)) +func LastModifiedAtIn(vs ...time.Time) predicate.Quest { + return predicate.Quest(sql.FieldIn(FieldLastModifiedAt, vs...)) } // LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. -func LastModifiedAtNotIn(vs ...time.Time) predicate.Job { - return predicate.Job(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +func LastModifiedAtNotIn(vs ...time.Time) predicate.Quest { + return predicate.Quest(sql.FieldNotIn(FieldLastModifiedAt, vs...)) } // LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. -func LastModifiedAtGT(v time.Time) predicate.Job { - return predicate.Job(sql.FieldGT(FieldLastModifiedAt, v)) +func LastModifiedAtGT(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldGT(FieldLastModifiedAt, v)) } // LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. -func LastModifiedAtGTE(v time.Time) predicate.Job { - return predicate.Job(sql.FieldGTE(FieldLastModifiedAt, v)) +func LastModifiedAtGTE(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldGTE(FieldLastModifiedAt, v)) } // LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. -func LastModifiedAtLT(v time.Time) predicate.Job { - return predicate.Job(sql.FieldLT(FieldLastModifiedAt, v)) +func LastModifiedAtLT(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldLT(FieldLastModifiedAt, v)) } // LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. -func LastModifiedAtLTE(v time.Time) predicate.Job { - return predicate.Job(sql.FieldLTE(FieldLastModifiedAt, v)) +func LastModifiedAtLTE(v time.Time) predicate.Quest { + return predicate.Quest(sql.FieldLTE(FieldLastModifiedAt, v)) } // NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldName, v)) +func NameEQ(v string) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldName, v)) } // NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Job { - return predicate.Job(sql.FieldNEQ(FieldName, v)) +func NameNEQ(v string) predicate.Quest { + return predicate.Quest(sql.FieldNEQ(FieldName, v)) } // NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Job { - return predicate.Job(sql.FieldIn(FieldName, vs...)) +func NameIn(vs ...string) predicate.Quest { + return predicate.Quest(sql.FieldIn(FieldName, vs...)) } // NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Job { - return predicate.Job(sql.FieldNotIn(FieldName, vs...)) +func NameNotIn(vs ...string) predicate.Quest { + return predicate.Quest(sql.FieldNotIn(FieldName, vs...)) } // NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Job { - return predicate.Job(sql.FieldGT(FieldName, v)) +func NameGT(v string) predicate.Quest { + return predicate.Quest(sql.FieldGT(FieldName, v)) } // NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Job { - return predicate.Job(sql.FieldGTE(FieldName, v)) +func NameGTE(v string) predicate.Quest { + return predicate.Quest(sql.FieldGTE(FieldName, v)) } // NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Job { - return predicate.Job(sql.FieldLT(FieldName, v)) +func NameLT(v string) predicate.Quest { + return predicate.Quest(sql.FieldLT(FieldName, v)) } // NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Job { - return predicate.Job(sql.FieldLTE(FieldName, v)) +func NameLTE(v string) predicate.Quest { + return predicate.Quest(sql.FieldLTE(FieldName, v)) } // NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Job { - return predicate.Job(sql.FieldContains(FieldName, v)) +func NameContains(v string) predicate.Quest { + return predicate.Quest(sql.FieldContains(FieldName, v)) } // NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Job { - return predicate.Job(sql.FieldHasPrefix(FieldName, v)) +func NameHasPrefix(v string) predicate.Quest { + return predicate.Quest(sql.FieldHasPrefix(FieldName, v)) } // NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Job { - return predicate.Job(sql.FieldHasSuffix(FieldName, v)) +func NameHasSuffix(v string) predicate.Quest { + return predicate.Quest(sql.FieldHasSuffix(FieldName, v)) } // NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Job { - return predicate.Job(sql.FieldEqualFold(FieldName, v)) +func NameEqualFold(v string) predicate.Quest { + return predicate.Quest(sql.FieldEqualFold(FieldName, v)) } // NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Job { - return predicate.Job(sql.FieldContainsFold(FieldName, v)) +func NameContainsFold(v string) predicate.Quest { + return predicate.Quest(sql.FieldContainsFold(FieldName, v)) } // ParametersEQ applies the EQ predicate on the "parameters" field. -func ParametersEQ(v string) predicate.Job { - return predicate.Job(sql.FieldEQ(FieldParameters, v)) +func ParametersEQ(v string) predicate.Quest { + return predicate.Quest(sql.FieldEQ(FieldParameters, v)) } // ParametersNEQ applies the NEQ predicate on the "parameters" field. -func ParametersNEQ(v string) predicate.Job { - return predicate.Job(sql.FieldNEQ(FieldParameters, v)) +func ParametersNEQ(v string) predicate.Quest { + return predicate.Quest(sql.FieldNEQ(FieldParameters, v)) } // ParametersIn applies the In predicate on the "parameters" field. -func ParametersIn(vs ...string) predicate.Job { - return predicate.Job(sql.FieldIn(FieldParameters, vs...)) +func ParametersIn(vs ...string) predicate.Quest { + return predicate.Quest(sql.FieldIn(FieldParameters, vs...)) } // ParametersNotIn applies the NotIn predicate on the "parameters" field. -func ParametersNotIn(vs ...string) predicate.Job { - return predicate.Job(sql.FieldNotIn(FieldParameters, vs...)) +func ParametersNotIn(vs ...string) predicate.Quest { + return predicate.Quest(sql.FieldNotIn(FieldParameters, vs...)) } // ParametersGT applies the GT predicate on the "parameters" field. -func ParametersGT(v string) predicate.Job { - return predicate.Job(sql.FieldGT(FieldParameters, v)) +func ParametersGT(v string) predicate.Quest { + return predicate.Quest(sql.FieldGT(FieldParameters, v)) } // ParametersGTE applies the GTE predicate on the "parameters" field. -func ParametersGTE(v string) predicate.Job { - return predicate.Job(sql.FieldGTE(FieldParameters, v)) +func ParametersGTE(v string) predicate.Quest { + return predicate.Quest(sql.FieldGTE(FieldParameters, v)) } // ParametersLT applies the LT predicate on the "parameters" field. -func ParametersLT(v string) predicate.Job { - return predicate.Job(sql.FieldLT(FieldParameters, v)) +func ParametersLT(v string) predicate.Quest { + return predicate.Quest(sql.FieldLT(FieldParameters, v)) } // ParametersLTE applies the LTE predicate on the "parameters" field. -func ParametersLTE(v string) predicate.Job { - return predicate.Job(sql.FieldLTE(FieldParameters, v)) +func ParametersLTE(v string) predicate.Quest { + return predicate.Quest(sql.FieldLTE(FieldParameters, v)) } // ParametersContains applies the Contains predicate on the "parameters" field. -func ParametersContains(v string) predicate.Job { - return predicate.Job(sql.FieldContains(FieldParameters, v)) +func ParametersContains(v string) predicate.Quest { + return predicate.Quest(sql.FieldContains(FieldParameters, v)) } // ParametersHasPrefix applies the HasPrefix predicate on the "parameters" field. -func ParametersHasPrefix(v string) predicate.Job { - return predicate.Job(sql.FieldHasPrefix(FieldParameters, v)) +func ParametersHasPrefix(v string) predicate.Quest { + return predicate.Quest(sql.FieldHasPrefix(FieldParameters, v)) } // ParametersHasSuffix applies the HasSuffix predicate on the "parameters" field. -func ParametersHasSuffix(v string) predicate.Job { - return predicate.Job(sql.FieldHasSuffix(FieldParameters, v)) +func ParametersHasSuffix(v string) predicate.Quest { + return predicate.Quest(sql.FieldHasSuffix(FieldParameters, v)) } // ParametersIsNil applies the IsNil predicate on the "parameters" field. -func ParametersIsNil() predicate.Job { - return predicate.Job(sql.FieldIsNull(FieldParameters)) +func ParametersIsNil() predicate.Quest { + return predicate.Quest(sql.FieldIsNull(FieldParameters)) } // ParametersNotNil applies the NotNil predicate on the "parameters" field. -func ParametersNotNil() predicate.Job { - return predicate.Job(sql.FieldNotNull(FieldParameters)) +func ParametersNotNil() predicate.Quest { + return predicate.Quest(sql.FieldNotNull(FieldParameters)) } // ParametersEqualFold applies the EqualFold predicate on the "parameters" field. -func ParametersEqualFold(v string) predicate.Job { - return predicate.Job(sql.FieldEqualFold(FieldParameters, v)) +func ParametersEqualFold(v string) predicate.Quest { + return predicate.Quest(sql.FieldEqualFold(FieldParameters, v)) } // ParametersContainsFold applies the ContainsFold predicate on the "parameters" field. -func ParametersContainsFold(v string) predicate.Job { - return predicate.Job(sql.FieldContainsFold(FieldParameters, v)) +func ParametersContainsFold(v string) predicate.Quest { + return predicate.Quest(sql.FieldContainsFold(FieldParameters, v)) } // HasTome applies the HasEdge predicate on the "tome" edge. -func HasTome() predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasTome() predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.Edge(sqlgraph.M2O, false, TomeTable, TomeColumn), @@ -307,8 +307,8 @@ func HasTome() predicate.Job { } // HasTomeWith applies the HasEdge predicate on the "tome" edge with a given conditions (other predicates). -func HasTomeWith(preds ...predicate.Tome) predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasTomeWith(preds ...predicate.Tome) predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(TomeInverseTable, FieldID), @@ -323,8 +323,8 @@ func HasTomeWith(preds ...predicate.Tome) predicate.Job { } // HasBundle applies the HasEdge predicate on the "bundle" edge. -func HasBundle() predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasBundle() predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.Edge(sqlgraph.M2O, false, BundleTable, BundleColumn), @@ -334,8 +334,8 @@ func HasBundle() predicate.Job { } // HasBundleWith applies the HasEdge predicate on the "bundle" edge with a given conditions (other predicates). -func HasBundleWith(preds ...predicate.File) predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasBundleWith(preds ...predicate.File) predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(BundleInverseTable, FieldID), @@ -350,8 +350,8 @@ func HasBundleWith(preds ...predicate.File) predicate.Job { } // HasTasks applies the HasEdge predicate on the "tasks" edge. -func HasTasks() predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasTasks() predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, TasksTable, TasksColumn), @@ -361,8 +361,8 @@ func HasTasks() predicate.Job { } // HasTasksWith applies the HasEdge predicate on the "tasks" edge with a given conditions (other predicates). -func HasTasksWith(preds ...predicate.Task) predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasTasksWith(preds ...predicate.Task) predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(TasksInverseTable, FieldID), @@ -377,8 +377,8 @@ func HasTasksWith(preds ...predicate.Task) predicate.Job { } // HasCreator applies the HasEdge predicate on the "creator" edge. -func HasCreator() predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasCreator() predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.Edge(sqlgraph.M2O, false, CreatorTable, CreatorColumn), @@ -388,8 +388,8 @@ func HasCreator() predicate.Job { } // HasCreatorWith applies the HasEdge predicate on the "creator" edge with a given conditions (other predicates). -func HasCreatorWith(preds ...predicate.User) predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func HasCreatorWith(preds ...predicate.User) predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(CreatorInverseTable, FieldID), @@ -404,8 +404,8 @@ func HasCreatorWith(preds ...predicate.User) predicate.Job { } // And groups predicates with the AND operator between them. -func And(predicates ...predicate.Job) predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func And(predicates ...predicate.Quest) predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { s1 := s.Clone().SetP(nil) for _, p := range predicates { p(s1) @@ -415,8 +415,8 @@ func And(predicates ...predicate.Job) predicate.Job { } // Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Job) predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func Or(predicates ...predicate.Quest) predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { s1 := s.Clone().SetP(nil) for i, p := range predicates { if i > 0 { @@ -429,8 +429,8 @@ func Or(predicates ...predicate.Job) predicate.Job { } // Not applies the not operator on the given predicate. -func Not(p predicate.Job) predicate.Job { - return predicate.Job(func(s *sql.Selector) { +func Not(p predicate.Quest) predicate.Quest { + return predicate.Quest(func(s *sql.Selector) { p(s.Not()) }) } diff --git a/tavern/ent/quest_create.go b/tavern/ent/quest_create.go new file mode 100644 index 000000000..f52d4804a --- /dev/null +++ b/tavern/ent/quest_create.go @@ -0,0 +1,409 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/kcarretto/realm/tavern/ent/file" + "github.com/kcarretto/realm/tavern/ent/quest" + "github.com/kcarretto/realm/tavern/ent/task" + "github.com/kcarretto/realm/tavern/ent/tome" + "github.com/kcarretto/realm/tavern/ent/user" +) + +// QuestCreate is the builder for creating a Quest entity. +type QuestCreate struct { + config + mutation *QuestMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (qc *QuestCreate) SetCreatedAt(t time.Time) *QuestCreate { + qc.mutation.SetCreatedAt(t) + return qc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (qc *QuestCreate) SetNillableCreatedAt(t *time.Time) *QuestCreate { + if t != nil { + qc.SetCreatedAt(*t) + } + return qc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (qc *QuestCreate) SetLastModifiedAt(t time.Time) *QuestCreate { + qc.mutation.SetLastModifiedAt(t) + return qc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (qc *QuestCreate) SetNillableLastModifiedAt(t *time.Time) *QuestCreate { + if t != nil { + qc.SetLastModifiedAt(*t) + } + return qc +} + +// SetName sets the "name" field. +func (qc *QuestCreate) SetName(s string) *QuestCreate { + qc.mutation.SetName(s) + return qc +} + +// SetParameters sets the "parameters" field. +func (qc *QuestCreate) SetParameters(s string) *QuestCreate { + qc.mutation.SetParameters(s) + return qc +} + +// SetNillableParameters sets the "parameters" field if the given value is not nil. +func (qc *QuestCreate) SetNillableParameters(s *string) *QuestCreate { + if s != nil { + qc.SetParameters(*s) + } + return qc +} + +// SetTomeID sets the "tome" edge to the Tome entity by ID. +func (qc *QuestCreate) SetTomeID(id int) *QuestCreate { + qc.mutation.SetTomeID(id) + return qc +} + +// SetTome sets the "tome" edge to the Tome entity. +func (qc *QuestCreate) SetTome(t *Tome) *QuestCreate { + return qc.SetTomeID(t.ID) +} + +// SetBundleID sets the "bundle" edge to the File entity by ID. +func (qc *QuestCreate) SetBundleID(id int) *QuestCreate { + qc.mutation.SetBundleID(id) + return qc +} + +// SetNillableBundleID sets the "bundle" edge to the File entity by ID if the given value is not nil. +func (qc *QuestCreate) SetNillableBundleID(id *int) *QuestCreate { + if id != nil { + qc = qc.SetBundleID(*id) + } + return qc +} + +// SetBundle sets the "bundle" edge to the File entity. +func (qc *QuestCreate) SetBundle(f *File) *QuestCreate { + return qc.SetBundleID(f.ID) +} + +// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. +func (qc *QuestCreate) AddTaskIDs(ids ...int) *QuestCreate { + qc.mutation.AddTaskIDs(ids...) + return qc +} + +// AddTasks adds the "tasks" edges to the Task entity. +func (qc *QuestCreate) AddTasks(t ...*Task) *QuestCreate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return qc.AddTaskIDs(ids...) +} + +// SetCreatorID sets the "creator" edge to the User entity by ID. +func (qc *QuestCreate) SetCreatorID(id int) *QuestCreate { + qc.mutation.SetCreatorID(id) + return qc +} + +// SetNillableCreatorID sets the "creator" edge to the User entity by ID if the given value is not nil. +func (qc *QuestCreate) SetNillableCreatorID(id *int) *QuestCreate { + if id != nil { + qc = qc.SetCreatorID(*id) + } + return qc +} + +// SetCreator sets the "creator" edge to the User entity. +func (qc *QuestCreate) SetCreator(u *User) *QuestCreate { + return qc.SetCreatorID(u.ID) +} + +// Mutation returns the QuestMutation object of the builder. +func (qc *QuestCreate) Mutation() *QuestMutation { + return qc.mutation +} + +// Save creates the Quest in the database. +func (qc *QuestCreate) Save(ctx context.Context) (*Quest, error) { + qc.defaults() + return withHooks[*Quest, QuestMutation](ctx, qc.sqlSave, qc.mutation, qc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (qc *QuestCreate) SaveX(ctx context.Context) *Quest { + v, err := qc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (qc *QuestCreate) Exec(ctx context.Context) error { + _, err := qc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (qc *QuestCreate) ExecX(ctx context.Context) { + if err := qc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (qc *QuestCreate) defaults() { + if _, ok := qc.mutation.CreatedAt(); !ok { + v := quest.DefaultCreatedAt() + qc.mutation.SetCreatedAt(v) + } + if _, ok := qc.mutation.LastModifiedAt(); !ok { + v := quest.DefaultLastModifiedAt() + qc.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (qc *QuestCreate) check() error { + if _, ok := qc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Quest.created_at"`)} + } + if _, ok := qc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Quest.last_modified_at"`)} + } + if _, ok := qc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Quest.name"`)} + } + if v, ok := qc.mutation.Name(); ok { + if err := quest.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Quest.name": %w`, err)} + } + } + if _, ok := qc.mutation.TomeID(); !ok { + return &ValidationError{Name: "tome", err: errors.New(`ent: missing required edge "Quest.tome"`)} + } + return nil +} + +func (qc *QuestCreate) sqlSave(ctx context.Context) (*Quest, error) { + if err := qc.check(); err != nil { + return nil, err + } + _node, _spec := qc.createSpec() + if err := sqlgraph.CreateNode(ctx, qc.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) + qc.mutation.id = &_node.ID + qc.mutation.done = true + return _node, nil +} + +func (qc *QuestCreate) createSpec() (*Quest, *sqlgraph.CreateSpec) { + var ( + _node = &Quest{config: qc.config} + _spec = sqlgraph.NewCreateSpec(quest.Table, sqlgraph.NewFieldSpec(quest.FieldID, field.TypeInt)) + ) + if value, ok := qc.mutation.CreatedAt(); ok { + _spec.SetField(quest.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := qc.mutation.LastModifiedAt(); ok { + _spec.SetField(quest.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := qc.mutation.Name(); ok { + _spec.SetField(quest.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := qc.mutation.Parameters(); ok { + _spec.SetField(quest.FieldParameters, field.TypeString, value) + _node.Parameters = value + } + if nodes := qc.mutation.TomeIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: quest.TomeTable, + Columns: []string{quest.TomeColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: tome.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.quest_tome = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := qc.mutation.BundleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: quest.BundleTable, + Columns: []string{quest.BundleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: file.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.quest_bundle = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := qc.mutation.TasksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: quest.TasksTable, + Columns: []string{quest.TasksColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: task.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := qc.mutation.CreatorIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: quest.CreatorTable, + Columns: []string{quest.CreatorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: user.FieldID, + }, + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.quest_creator = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// QuestCreateBulk is the builder for creating many Quest entities in bulk. +type QuestCreateBulk struct { + config + builders []*QuestCreate +} + +// Save creates the Quest entities in the database. +func (qcb *QuestCreateBulk) Save(ctx context.Context) ([]*Quest, error) { + specs := make([]*sqlgraph.CreateSpec, len(qcb.builders)) + nodes := make([]*Quest, len(qcb.builders)) + mutators := make([]Mutator, len(qcb.builders)) + for i := range qcb.builders { + func(i int, root context.Context) { + builder := qcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*QuestMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + nodes[i], specs[i] = builder.createSpec() + var err error + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, qcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, qcb.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, qcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (qcb *QuestCreateBulk) SaveX(ctx context.Context) []*Quest { + v, err := qcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (qcb *QuestCreateBulk) Exec(ctx context.Context) error { + _, err := qcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (qcb *QuestCreateBulk) ExecX(ctx context.Context) { + if err := qcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/ent/quest_delete.go b/tavern/ent/quest_delete.go new file mode 100644 index 000000000..4e9604bef --- /dev/null +++ b/tavern/ent/quest_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" + "github.com/kcarretto/realm/tavern/ent/predicate" + "github.com/kcarretto/realm/tavern/ent/quest" +) + +// QuestDelete is the builder for deleting a Quest entity. +type QuestDelete struct { + config + hooks []Hook + mutation *QuestMutation +} + +// Where appends a list predicates to the QuestDelete builder. +func (qd *QuestDelete) Where(ps ...predicate.Quest) *QuestDelete { + qd.mutation.Where(ps...) + return qd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (qd *QuestDelete) Exec(ctx context.Context) (int, error) { + return withHooks[int, QuestMutation](ctx, qd.sqlExec, qd.mutation, qd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (qd *QuestDelete) ExecX(ctx context.Context) int { + n, err := qd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (qd *QuestDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(quest.Table, sqlgraph.NewFieldSpec(quest.FieldID, field.TypeInt)) + if ps := qd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, qd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + qd.mutation.done = true + return affected, err +} + +// QuestDeleteOne is the builder for deleting a single Quest entity. +type QuestDeleteOne struct { + qd *QuestDelete +} + +// Where appends a list predicates to the QuestDelete builder. +func (qdo *QuestDeleteOne) Where(ps ...predicate.Quest) *QuestDeleteOne { + qdo.qd.mutation.Where(ps...) + return qdo +} + +// Exec executes the deletion query. +func (qdo *QuestDeleteOne) Exec(ctx context.Context) error { + n, err := qdo.qd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{quest.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (qdo *QuestDeleteOne) ExecX(ctx context.Context) { + if err := qdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/ent/quest_query.go b/tavern/ent/quest_query.go new file mode 100644 index 000000000..20e7c3688 --- /dev/null +++ b/tavern/ent/quest_query.go @@ -0,0 +1,874 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/kcarretto/realm/tavern/ent/file" + "github.com/kcarretto/realm/tavern/ent/predicate" + "github.com/kcarretto/realm/tavern/ent/quest" + "github.com/kcarretto/realm/tavern/ent/task" + "github.com/kcarretto/realm/tavern/ent/tome" + "github.com/kcarretto/realm/tavern/ent/user" +) + +// QuestQuery is the builder for querying Quest entities. +type QuestQuery struct { + config + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Quest + withTome *TomeQuery + withBundle *FileQuery + withTasks *TaskQuery + withCreator *UserQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Quest) error + withNamedTasks map[string]*TaskQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the QuestQuery builder. +func (qq *QuestQuery) Where(ps ...predicate.Quest) *QuestQuery { + qq.predicates = append(qq.predicates, ps...) + return qq +} + +// Limit the number of records to be returned by this query. +func (qq *QuestQuery) Limit(limit int) *QuestQuery { + qq.ctx.Limit = &limit + return qq +} + +// Offset to start from. +func (qq *QuestQuery) Offset(offset int) *QuestQuery { + qq.ctx.Offset = &offset + return qq +} + +// 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 (qq *QuestQuery) Unique(unique bool) *QuestQuery { + qq.ctx.Unique = &unique + return qq +} + +// Order specifies how the records should be ordered. +func (qq *QuestQuery) Order(o ...OrderFunc) *QuestQuery { + qq.order = append(qq.order, o...) + return qq +} + +// QueryTome chains the current query on the "tome" edge. +func (qq *QuestQuery) QueryTome() *TomeQuery { + query := (&TomeClient{config: qq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := qq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := qq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(quest.Table, quest.FieldID, selector), + sqlgraph.To(tome.Table, tome.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, quest.TomeTable, quest.TomeColumn), + ) + fromU = sqlgraph.SetNeighbors(qq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryBundle chains the current query on the "bundle" edge. +func (qq *QuestQuery) QueryBundle() *FileQuery { + query := (&FileClient{config: qq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := qq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := qq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(quest.Table, quest.FieldID, selector), + sqlgraph.To(file.Table, file.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, quest.BundleTable, quest.BundleColumn), + ) + fromU = sqlgraph.SetNeighbors(qq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTasks chains the current query on the "tasks" edge. +func (qq *QuestQuery) QueryTasks() *TaskQuery { + query := (&TaskClient{config: qq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := qq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := qq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(quest.Table, quest.FieldID, selector), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, quest.TasksTable, quest.TasksColumn), + ) + fromU = sqlgraph.SetNeighbors(qq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryCreator chains the current query on the "creator" edge. +func (qq *QuestQuery) QueryCreator() *UserQuery { + query := (&UserClient{config: qq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := qq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := qq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(quest.Table, quest.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, quest.CreatorTable, quest.CreatorColumn), + ) + fromU = sqlgraph.SetNeighbors(qq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Quest entity from the query. +// Returns a *NotFoundError when no Quest was found. +func (qq *QuestQuery) First(ctx context.Context) (*Quest, error) { + nodes, err := qq.Limit(1).All(setContextOp(ctx, qq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{quest.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (qq *QuestQuery) FirstX(ctx context.Context) *Quest { + node, err := qq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Quest ID from the query. +// Returns a *NotFoundError when no Quest ID was found. +func (qq *QuestQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = qq.Limit(1).IDs(setContextOp(ctx, qq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{quest.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (qq *QuestQuery) FirstIDX(ctx context.Context) int { + id, err := qq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Quest entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Quest entity is found. +// Returns a *NotFoundError when no Quest entities are found. +func (qq *QuestQuery) Only(ctx context.Context) (*Quest, error) { + nodes, err := qq.Limit(2).All(setContextOp(ctx, qq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{quest.Label} + default: + return nil, &NotSingularError{quest.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (qq *QuestQuery) OnlyX(ctx context.Context) *Quest { + node, err := qq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Quest ID in the query. +// Returns a *NotSingularError when more than one Quest ID is found. +// Returns a *NotFoundError when no entities are found. +func (qq *QuestQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = qq.Limit(2).IDs(setContextOp(ctx, qq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{quest.Label} + default: + err = &NotSingularError{quest.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (qq *QuestQuery) OnlyIDX(ctx context.Context) int { + id, err := qq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Quests. +func (qq *QuestQuery) All(ctx context.Context) ([]*Quest, error) { + ctx = setContextOp(ctx, qq.ctx, "All") + if err := qq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Quest, *QuestQuery]() + return withInterceptors[[]*Quest](ctx, qq, qr, qq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (qq *QuestQuery) AllX(ctx context.Context) []*Quest { + nodes, err := qq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Quest IDs. +func (qq *QuestQuery) IDs(ctx context.Context) (ids []int, err error) { + if qq.ctx.Unique == nil && qq.path != nil { + qq.Unique(true) + } + ctx = setContextOp(ctx, qq.ctx, "IDs") + if err = qq.Select(quest.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (qq *QuestQuery) IDsX(ctx context.Context) []int { + ids, err := qq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (qq *QuestQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, qq.ctx, "Count") + if err := qq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, qq, querierCount[*QuestQuery](), qq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (qq *QuestQuery) CountX(ctx context.Context) int { + count, err := qq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (qq *QuestQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, qq.ctx, "Exist") + switch _, err := qq.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 (qq *QuestQuery) ExistX(ctx context.Context) bool { + exist, err := qq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the QuestQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (qq *QuestQuery) Clone() *QuestQuery { + if qq == nil { + return nil + } + return &QuestQuery{ + config: qq.config, + ctx: qq.ctx.Clone(), + order: append([]OrderFunc{}, qq.order...), + inters: append([]Interceptor{}, qq.inters...), + predicates: append([]predicate.Quest{}, qq.predicates...), + withTome: qq.withTome.Clone(), + withBundle: qq.withBundle.Clone(), + withTasks: qq.withTasks.Clone(), + withCreator: qq.withCreator.Clone(), + // clone intermediate query. + sql: qq.sql.Clone(), + path: qq.path, + } +} + +// WithTome tells the query-builder to eager-load the nodes that are connected to +// the "tome" edge. The optional arguments are used to configure the query builder of the edge. +func (qq *QuestQuery) WithTome(opts ...func(*TomeQuery)) *QuestQuery { + query := (&TomeClient{config: qq.config}).Query() + for _, opt := range opts { + opt(query) + } + qq.withTome = query + return qq +} + +// WithBundle tells the query-builder to eager-load the nodes that are connected to +// the "bundle" edge. The optional arguments are used to configure the query builder of the edge. +func (qq *QuestQuery) WithBundle(opts ...func(*FileQuery)) *QuestQuery { + query := (&FileClient{config: qq.config}).Query() + for _, opt := range opts { + opt(query) + } + qq.withBundle = query + return qq +} + +// WithTasks tells the query-builder to eager-load the nodes that are connected to +// the "tasks" edge. The optional arguments are used to configure the query builder of the edge. +func (qq *QuestQuery) WithTasks(opts ...func(*TaskQuery)) *QuestQuery { + query := (&TaskClient{config: qq.config}).Query() + for _, opt := range opts { + opt(query) + } + qq.withTasks = query + return qq +} + +// WithCreator tells the query-builder to eager-load the nodes that are connected to +// the "creator" edge. The optional arguments are used to configure the query builder of the edge. +func (qq *QuestQuery) WithCreator(opts ...func(*UserQuery)) *QuestQuery { + query := (&UserClient{config: qq.config}).Query() + for _, opt := range opts { + opt(query) + } + qq.withCreator = query + return qq +} + +// 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.Quest.Query(). +// GroupBy(quest.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (qq *QuestQuery) GroupBy(field string, fields ...string) *QuestGroupBy { + qq.ctx.Fields = append([]string{field}, fields...) + grbuild := &QuestGroupBy{build: qq} + grbuild.flds = &qq.ctx.Fields + grbuild.label = quest.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.Quest.Query(). +// Select(quest.FieldCreatedAt). +// Scan(ctx, &v) +func (qq *QuestQuery) Select(fields ...string) *QuestSelect { + qq.ctx.Fields = append(qq.ctx.Fields, fields...) + sbuild := &QuestSelect{QuestQuery: qq} + sbuild.label = quest.Label + sbuild.flds, sbuild.scan = &qq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a QuestSelect configured with the given aggregations. +func (qq *QuestQuery) Aggregate(fns ...AggregateFunc) *QuestSelect { + return qq.Select().Aggregate(fns...) +} + +func (qq *QuestQuery) prepareQuery(ctx context.Context) error { + for _, inter := range qq.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, qq); err != nil { + return err + } + } + } + for _, f := range qq.ctx.Fields { + if !quest.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if qq.path != nil { + prev, err := qq.path(ctx) + if err != nil { + return err + } + qq.sql = prev + } + return nil +} + +func (qq *QuestQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Quest, error) { + var ( + nodes = []*Quest{} + withFKs = qq.withFKs + _spec = qq.querySpec() + loadedTypes = [4]bool{ + qq.withTome != nil, + qq.withBundle != nil, + qq.withTasks != nil, + qq.withCreator != nil, + } + ) + if qq.withTome != nil || qq.withBundle != nil || qq.withCreator != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, quest.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Quest).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Quest{config: qq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(qq.modifiers) > 0 { + _spec.Modifiers = qq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, qq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := qq.withTome; query != nil { + if err := qq.loadTome(ctx, query, nodes, nil, + func(n *Quest, e *Tome) { n.Edges.Tome = e }); err != nil { + return nil, err + } + } + if query := qq.withBundle; query != nil { + if err := qq.loadBundle(ctx, query, nodes, nil, + func(n *Quest, e *File) { n.Edges.Bundle = e }); err != nil { + return nil, err + } + } + if query := qq.withTasks; query != nil { + if err := qq.loadTasks(ctx, query, nodes, + func(n *Quest) { n.Edges.Tasks = []*Task{} }, + func(n *Quest, e *Task) { n.Edges.Tasks = append(n.Edges.Tasks, e) }); err != nil { + return nil, err + } + } + if query := qq.withCreator; query != nil { + if err := qq.loadCreator(ctx, query, nodes, nil, + func(n *Quest, e *User) { n.Edges.Creator = e }); err != nil { + return nil, err + } + } + for name, query := range qq.withNamedTasks { + if err := qq.loadTasks(ctx, query, nodes, + func(n *Quest) { n.appendNamedTasks(name) }, + func(n *Quest, e *Task) { n.appendNamedTasks(name, e) }); err != nil { + return nil, err + } + } + for i := range qq.loadTotal { + if err := qq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (qq *QuestQuery) loadTome(ctx context.Context, query *TomeQuery, nodes []*Quest, init func(*Quest), assign func(*Quest, *Tome)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Quest) + for i := range nodes { + if nodes[i].quest_tome == nil { + continue + } + fk := *nodes[i].quest_tome + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(tome.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 "quest_tome" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (qq *QuestQuery) loadBundle(ctx context.Context, query *FileQuery, nodes []*Quest, init func(*Quest), assign func(*Quest, *File)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Quest) + for i := range nodes { + if nodes[i].quest_bundle == nil { + continue + } + fk := *nodes[i].quest_bundle + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(file.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 "quest_bundle" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (qq *QuestQuery) loadTasks(ctx context.Context, query *TaskQuery, nodes []*Quest, init func(*Quest), assign func(*Quest, *Task)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Quest) + 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.Task(func(s *sql.Selector) { + s.Where(sql.InValues(quest.TasksColumn, fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.quest_tasks + if fk == nil { + return fmt.Errorf(`foreign-key "quest_tasks" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected foreign-key "quest_tasks" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (qq *QuestQuery) loadCreator(ctx context.Context, query *UserQuery, nodes []*Quest, init func(*Quest), assign func(*Quest, *User)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Quest) + for i := range nodes { + if nodes[i].quest_creator == nil { + continue + } + fk := *nodes[i].quest_creator + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "quest_creator" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (qq *QuestQuery) sqlCount(ctx context.Context) (int, error) { + _spec := qq.querySpec() + if len(qq.modifiers) > 0 { + _spec.Modifiers = qq.modifiers + } + _spec.Node.Columns = qq.ctx.Fields + if len(qq.ctx.Fields) > 0 { + _spec.Unique = qq.ctx.Unique != nil && *qq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, qq.driver, _spec) +} + +func (qq *QuestQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(quest.Table, quest.Columns, sqlgraph.NewFieldSpec(quest.FieldID, field.TypeInt)) + _spec.From = qq.sql + if unique := qq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if qq.path != nil { + _spec.Unique = true + } + if fields := qq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, quest.FieldID) + for i := range fields { + if fields[i] != quest.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := qq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := qq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := qq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := qq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (qq *QuestQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(qq.driver.Dialect()) + t1 := builder.Table(quest.Table) + columns := qq.ctx.Fields + if len(columns) == 0 { + columns = quest.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if qq.sql != nil { + selector = qq.sql + selector.Select(selector.Columns(columns...)...) + } + if qq.ctx.Unique != nil && *qq.ctx.Unique { + selector.Distinct() + } + for _, p := range qq.predicates { + p(selector) + } + for _, p := range qq.order { + p(selector) + } + if offset := qq.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 := qq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// WithNamedTasks tells the query-builder to eager-load the nodes that are connected to the "tasks" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (qq *QuestQuery) WithNamedTasks(name string, opts ...func(*TaskQuery)) *QuestQuery { + query := (&TaskClient{config: qq.config}).Query() + for _, opt := range opts { + opt(query) + } + if qq.withNamedTasks == nil { + qq.withNamedTasks = make(map[string]*TaskQuery) + } + qq.withNamedTasks[name] = query + return qq +} + +// QuestGroupBy is the group-by builder for Quest entities. +type QuestGroupBy struct { + selector + build *QuestQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (qgb *QuestGroupBy) Aggregate(fns ...AggregateFunc) *QuestGroupBy { + qgb.fns = append(qgb.fns, fns...) + return qgb +} + +// Scan applies the selector query and scans the result into the given value. +func (qgb *QuestGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, qgb.build.ctx, "GroupBy") + if err := qgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*QuestQuery, *QuestGroupBy](ctx, qgb.build, qgb, qgb.build.inters, v) +} + +func (qgb *QuestGroupBy) sqlScan(ctx context.Context, root *QuestQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(qgb.fns)) + for _, fn := range qgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*qgb.flds)+len(qgb.fns)) + for _, f := range *qgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*qgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := qgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// QuestSelect is the builder for selecting fields of Quest entities. +type QuestSelect struct { + *QuestQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (qs *QuestSelect) Aggregate(fns ...AggregateFunc) *QuestSelect { + qs.fns = append(qs.fns, fns...) + return qs +} + +// Scan applies the selector query and scans the result into the given value. +func (qs *QuestSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, qs.ctx, "Select") + if err := qs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*QuestQuery, *QuestSelect](ctx, qs.QuestQuery, qs, qs.inters, v) +} + +func (qs *QuestSelect) sqlScan(ctx context.Context, root *QuestQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(qs.fns)) + for _, fn := range qs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*qs.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 := qs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/ent/job_update.go b/tavern/ent/quest_update.go similarity index 51% rename from tavern/ent/job_update.go rename to tavern/ent/quest_update.go index af4a9af0d..979e75f98 100644 --- a/tavern/ent/job_update.go +++ b/tavern/ent/quest_update.go @@ -12,175 +12,175 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" "github.com/kcarretto/realm/tavern/ent/predicate" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" "github.com/kcarretto/realm/tavern/ent/user" ) -// JobUpdate is the builder for updating Job entities. -type JobUpdate struct { +// QuestUpdate is the builder for updating Quest entities. +type QuestUpdate struct { config hooks []Hook - mutation *JobMutation + mutation *QuestMutation } -// Where appends a list predicates to the JobUpdate builder. -func (ju *JobUpdate) Where(ps ...predicate.Job) *JobUpdate { - ju.mutation.Where(ps...) - return ju +// Where appends a list predicates to the QuestUpdate builder. +func (qu *QuestUpdate) Where(ps ...predicate.Quest) *QuestUpdate { + qu.mutation.Where(ps...) + return qu } // SetLastModifiedAt sets the "last_modified_at" field. -func (ju *JobUpdate) SetLastModifiedAt(t time.Time) *JobUpdate { - ju.mutation.SetLastModifiedAt(t) - return ju +func (qu *QuestUpdate) SetLastModifiedAt(t time.Time) *QuestUpdate { + qu.mutation.SetLastModifiedAt(t) + return qu } // SetName sets the "name" field. -func (ju *JobUpdate) SetName(s string) *JobUpdate { - ju.mutation.SetName(s) - return ju +func (qu *QuestUpdate) SetName(s string) *QuestUpdate { + qu.mutation.SetName(s) + return qu } // SetParameters sets the "parameters" field. -func (ju *JobUpdate) SetParameters(s string) *JobUpdate { - ju.mutation.SetParameters(s) - return ju +func (qu *QuestUpdate) SetParameters(s string) *QuestUpdate { + qu.mutation.SetParameters(s) + return qu } // SetNillableParameters sets the "parameters" field if the given value is not nil. -func (ju *JobUpdate) SetNillableParameters(s *string) *JobUpdate { +func (qu *QuestUpdate) SetNillableParameters(s *string) *QuestUpdate { if s != nil { - ju.SetParameters(*s) + qu.SetParameters(*s) } - return ju + return qu } // ClearParameters clears the value of the "parameters" field. -func (ju *JobUpdate) ClearParameters() *JobUpdate { - ju.mutation.ClearParameters() - return ju +func (qu *QuestUpdate) ClearParameters() *QuestUpdate { + qu.mutation.ClearParameters() + return qu } // SetTomeID sets the "tome" edge to the Tome entity by ID. -func (ju *JobUpdate) SetTomeID(id int) *JobUpdate { - ju.mutation.SetTomeID(id) - return ju +func (qu *QuestUpdate) SetTomeID(id int) *QuestUpdate { + qu.mutation.SetTomeID(id) + return qu } // SetTome sets the "tome" edge to the Tome entity. -func (ju *JobUpdate) SetTome(t *Tome) *JobUpdate { - return ju.SetTomeID(t.ID) +func (qu *QuestUpdate) SetTome(t *Tome) *QuestUpdate { + return qu.SetTomeID(t.ID) } // SetBundleID sets the "bundle" edge to the File entity by ID. -func (ju *JobUpdate) SetBundleID(id int) *JobUpdate { - ju.mutation.SetBundleID(id) - return ju +func (qu *QuestUpdate) SetBundleID(id int) *QuestUpdate { + qu.mutation.SetBundleID(id) + return qu } // SetNillableBundleID sets the "bundle" edge to the File entity by ID if the given value is not nil. -func (ju *JobUpdate) SetNillableBundleID(id *int) *JobUpdate { +func (qu *QuestUpdate) SetNillableBundleID(id *int) *QuestUpdate { if id != nil { - ju = ju.SetBundleID(*id) + qu = qu.SetBundleID(*id) } - return ju + return qu } // SetBundle sets the "bundle" edge to the File entity. -func (ju *JobUpdate) SetBundle(f *File) *JobUpdate { - return ju.SetBundleID(f.ID) +func (qu *QuestUpdate) SetBundle(f *File) *QuestUpdate { + return qu.SetBundleID(f.ID) } // AddTaskIDs adds the "tasks" edge to the Task entity by IDs. -func (ju *JobUpdate) AddTaskIDs(ids ...int) *JobUpdate { - ju.mutation.AddTaskIDs(ids...) - return ju +func (qu *QuestUpdate) AddTaskIDs(ids ...int) *QuestUpdate { + qu.mutation.AddTaskIDs(ids...) + return qu } // AddTasks adds the "tasks" edges to the Task entity. -func (ju *JobUpdate) AddTasks(t ...*Task) *JobUpdate { +func (qu *QuestUpdate) AddTasks(t ...*Task) *QuestUpdate { ids := make([]int, len(t)) for i := range t { ids[i] = t[i].ID } - return ju.AddTaskIDs(ids...) + return qu.AddTaskIDs(ids...) } // SetCreatorID sets the "creator" edge to the User entity by ID. -func (ju *JobUpdate) SetCreatorID(id int) *JobUpdate { - ju.mutation.SetCreatorID(id) - return ju +func (qu *QuestUpdate) SetCreatorID(id int) *QuestUpdate { + qu.mutation.SetCreatorID(id) + return qu } // SetNillableCreatorID sets the "creator" edge to the User entity by ID if the given value is not nil. -func (ju *JobUpdate) SetNillableCreatorID(id *int) *JobUpdate { +func (qu *QuestUpdate) SetNillableCreatorID(id *int) *QuestUpdate { if id != nil { - ju = ju.SetCreatorID(*id) + qu = qu.SetCreatorID(*id) } - return ju + return qu } // SetCreator sets the "creator" edge to the User entity. -func (ju *JobUpdate) SetCreator(u *User) *JobUpdate { - return ju.SetCreatorID(u.ID) +func (qu *QuestUpdate) SetCreator(u *User) *QuestUpdate { + return qu.SetCreatorID(u.ID) } -// Mutation returns the JobMutation object of the builder. -func (ju *JobUpdate) Mutation() *JobMutation { - return ju.mutation +// Mutation returns the QuestMutation object of the builder. +func (qu *QuestUpdate) Mutation() *QuestMutation { + return qu.mutation } // ClearTome clears the "tome" edge to the Tome entity. -func (ju *JobUpdate) ClearTome() *JobUpdate { - ju.mutation.ClearTome() - return ju +func (qu *QuestUpdate) ClearTome() *QuestUpdate { + qu.mutation.ClearTome() + return qu } // ClearBundle clears the "bundle" edge to the File entity. -func (ju *JobUpdate) ClearBundle() *JobUpdate { - ju.mutation.ClearBundle() - return ju +func (qu *QuestUpdate) ClearBundle() *QuestUpdate { + qu.mutation.ClearBundle() + return qu } // ClearTasks clears all "tasks" edges to the Task entity. -func (ju *JobUpdate) ClearTasks() *JobUpdate { - ju.mutation.ClearTasks() - return ju +func (qu *QuestUpdate) ClearTasks() *QuestUpdate { + qu.mutation.ClearTasks() + return qu } // RemoveTaskIDs removes the "tasks" edge to Task entities by IDs. -func (ju *JobUpdate) RemoveTaskIDs(ids ...int) *JobUpdate { - ju.mutation.RemoveTaskIDs(ids...) - return ju +func (qu *QuestUpdate) RemoveTaskIDs(ids ...int) *QuestUpdate { + qu.mutation.RemoveTaskIDs(ids...) + return qu } // RemoveTasks removes "tasks" edges to Task entities. -func (ju *JobUpdate) RemoveTasks(t ...*Task) *JobUpdate { +func (qu *QuestUpdate) RemoveTasks(t ...*Task) *QuestUpdate { ids := make([]int, len(t)) for i := range t { ids[i] = t[i].ID } - return ju.RemoveTaskIDs(ids...) + return qu.RemoveTaskIDs(ids...) } // ClearCreator clears the "creator" edge to the User entity. -func (ju *JobUpdate) ClearCreator() *JobUpdate { - ju.mutation.ClearCreator() - return ju +func (qu *QuestUpdate) ClearCreator() *QuestUpdate { + qu.mutation.ClearCreator() + return qu } // Save executes the query and returns the number of nodes affected by the update operation. -func (ju *JobUpdate) Save(ctx context.Context) (int, error) { - ju.defaults() - return withHooks[int, JobMutation](ctx, ju.sqlSave, ju.mutation, ju.hooks) +func (qu *QuestUpdate) Save(ctx context.Context) (int, error) { + qu.defaults() + return withHooks[int, QuestMutation](ctx, qu.sqlSave, qu.mutation, qu.hooks) } // SaveX is like Save, but panics if an error occurs. -func (ju *JobUpdate) SaveX(ctx context.Context) int { - affected, err := ju.Save(ctx) +func (qu *QuestUpdate) SaveX(ctx context.Context) int { + affected, err := qu.Save(ctx) if err != nil { panic(err) } @@ -188,69 +188,69 @@ func (ju *JobUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (ju *JobUpdate) Exec(ctx context.Context) error { - _, err := ju.Save(ctx) +func (qu *QuestUpdate) Exec(ctx context.Context) error { + _, err := qu.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ju *JobUpdate) ExecX(ctx context.Context) { - if err := ju.Exec(ctx); err != nil { +func (qu *QuestUpdate) ExecX(ctx context.Context) { + if err := qu.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (ju *JobUpdate) defaults() { - if _, ok := ju.mutation.LastModifiedAt(); !ok { - v := job.UpdateDefaultLastModifiedAt() - ju.mutation.SetLastModifiedAt(v) +func (qu *QuestUpdate) defaults() { + if _, ok := qu.mutation.LastModifiedAt(); !ok { + v := quest.UpdateDefaultLastModifiedAt() + qu.mutation.SetLastModifiedAt(v) } } // check runs all checks and user-defined validators on the builder. -func (ju *JobUpdate) check() error { - if v, ok := ju.mutation.Name(); ok { - if err := job.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Job.name": %w`, err)} +func (qu *QuestUpdate) check() error { + if v, ok := qu.mutation.Name(); ok { + if err := quest.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Quest.name": %w`, err)} } } - if _, ok := ju.mutation.TomeID(); ju.mutation.TomeCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Job.tome"`) + if _, ok := qu.mutation.TomeID(); qu.mutation.TomeCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Quest.tome"`) } return nil } -func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := ju.check(); err != nil { +func (qu *QuestUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := qu.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(job.Table, job.Columns, sqlgraph.NewFieldSpec(job.FieldID, field.TypeInt)) - if ps := ju.mutation.predicates; len(ps) > 0 { + _spec := sqlgraph.NewUpdateSpec(quest.Table, quest.Columns, sqlgraph.NewFieldSpec(quest.FieldID, field.TypeInt)) + if ps := qu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := ju.mutation.LastModifiedAt(); ok { - _spec.SetField(job.FieldLastModifiedAt, field.TypeTime, value) + if value, ok := qu.mutation.LastModifiedAt(); ok { + _spec.SetField(quest.FieldLastModifiedAt, field.TypeTime, value) } - if value, ok := ju.mutation.Name(); ok { - _spec.SetField(job.FieldName, field.TypeString, value) + if value, ok := qu.mutation.Name(); ok { + _spec.SetField(quest.FieldName, field.TypeString, value) } - if value, ok := ju.mutation.Parameters(); ok { - _spec.SetField(job.FieldParameters, field.TypeString, value) + if value, ok := qu.mutation.Parameters(); ok { + _spec.SetField(quest.FieldParameters, field.TypeString, value) } - if ju.mutation.ParametersCleared() { - _spec.ClearField(job.FieldParameters, field.TypeString) + if qu.mutation.ParametersCleared() { + _spec.ClearField(quest.FieldParameters, field.TypeString) } - if ju.mutation.TomeCleared() { + if qu.mutation.TomeCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.TomeTable, - Columns: []string{job.TomeColumn}, + Table: quest.TomeTable, + Columns: []string{quest.TomeColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -261,12 +261,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ju.mutation.TomeIDs(); len(nodes) > 0 { + if nodes := qu.mutation.TomeIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.TomeTable, - Columns: []string{job.TomeColumn}, + Table: quest.TomeTable, + Columns: []string{quest.TomeColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -280,12 +280,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ju.mutation.BundleCleared() { + if qu.mutation.BundleCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.BundleTable, - Columns: []string{job.BundleColumn}, + Table: quest.BundleTable, + Columns: []string{quest.BundleColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -296,12 +296,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ju.mutation.BundleIDs(); len(nodes) > 0 { + if nodes := qu.mutation.BundleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.BundleTable, - Columns: []string{job.BundleColumn}, + Table: quest.BundleTable, + Columns: []string{quest.BundleColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -315,12 +315,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ju.mutation.TasksCleared() { + if qu.mutation.TasksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: job.TasksTable, - Columns: []string{job.TasksColumn}, + Table: quest.TasksTable, + Columns: []string{quest.TasksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -331,12 +331,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ju.mutation.RemovedTasksIDs(); len(nodes) > 0 && !ju.mutation.TasksCleared() { + if nodes := qu.mutation.RemovedTasksIDs(); len(nodes) > 0 && !qu.mutation.TasksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: job.TasksTable, - Columns: []string{job.TasksColumn}, + Table: quest.TasksTable, + Columns: []string{quest.TasksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -350,12 +350,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ju.mutation.TasksIDs(); len(nodes) > 0 { + if nodes := qu.mutation.TasksIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: job.TasksTable, - Columns: []string{job.TasksColumn}, + Table: quest.TasksTable, + Columns: []string{quest.TasksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -369,12 +369,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ju.mutation.CreatorCleared() { + if qu.mutation.CreatorCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.CreatorTable, - Columns: []string{job.CreatorColumn}, + Table: quest.CreatorTable, + Columns: []string{quest.CreatorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -385,12 +385,12 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ju.mutation.CreatorIDs(); len(nodes) > 0 { + if nodes := qu.mutation.CreatorIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.CreatorTable, - Columns: []string{job.CreatorColumn}, + Table: quest.CreatorTable, + Columns: []string{quest.CreatorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -404,188 +404,188 @@ func (ju *JobUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if n, err = sqlgraph.UpdateNodes(ctx, ju.driver, _spec); err != nil { + if n, err = sqlgraph.UpdateNodes(ctx, qu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{job.Label} + err = &NotFoundError{quest.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } - ju.mutation.done = true + qu.mutation.done = true return n, nil } -// JobUpdateOne is the builder for updating a single Job entity. -type JobUpdateOne struct { +// QuestUpdateOne is the builder for updating a single Quest entity. +type QuestUpdateOne struct { config fields []string hooks []Hook - mutation *JobMutation + mutation *QuestMutation } // SetLastModifiedAt sets the "last_modified_at" field. -func (juo *JobUpdateOne) SetLastModifiedAt(t time.Time) *JobUpdateOne { - juo.mutation.SetLastModifiedAt(t) - return juo +func (quo *QuestUpdateOne) SetLastModifiedAt(t time.Time) *QuestUpdateOne { + quo.mutation.SetLastModifiedAt(t) + return quo } // SetName sets the "name" field. -func (juo *JobUpdateOne) SetName(s string) *JobUpdateOne { - juo.mutation.SetName(s) - return juo +func (quo *QuestUpdateOne) SetName(s string) *QuestUpdateOne { + quo.mutation.SetName(s) + return quo } // SetParameters sets the "parameters" field. -func (juo *JobUpdateOne) SetParameters(s string) *JobUpdateOne { - juo.mutation.SetParameters(s) - return juo +func (quo *QuestUpdateOne) SetParameters(s string) *QuestUpdateOne { + quo.mutation.SetParameters(s) + return quo } // SetNillableParameters sets the "parameters" field if the given value is not nil. -func (juo *JobUpdateOne) SetNillableParameters(s *string) *JobUpdateOne { +func (quo *QuestUpdateOne) SetNillableParameters(s *string) *QuestUpdateOne { if s != nil { - juo.SetParameters(*s) + quo.SetParameters(*s) } - return juo + return quo } // ClearParameters clears the value of the "parameters" field. -func (juo *JobUpdateOne) ClearParameters() *JobUpdateOne { - juo.mutation.ClearParameters() - return juo +func (quo *QuestUpdateOne) ClearParameters() *QuestUpdateOne { + quo.mutation.ClearParameters() + return quo } // SetTomeID sets the "tome" edge to the Tome entity by ID. -func (juo *JobUpdateOne) SetTomeID(id int) *JobUpdateOne { - juo.mutation.SetTomeID(id) - return juo +func (quo *QuestUpdateOne) SetTomeID(id int) *QuestUpdateOne { + quo.mutation.SetTomeID(id) + return quo } // SetTome sets the "tome" edge to the Tome entity. -func (juo *JobUpdateOne) SetTome(t *Tome) *JobUpdateOne { - return juo.SetTomeID(t.ID) +func (quo *QuestUpdateOne) SetTome(t *Tome) *QuestUpdateOne { + return quo.SetTomeID(t.ID) } // SetBundleID sets the "bundle" edge to the File entity by ID. -func (juo *JobUpdateOne) SetBundleID(id int) *JobUpdateOne { - juo.mutation.SetBundleID(id) - return juo +func (quo *QuestUpdateOne) SetBundleID(id int) *QuestUpdateOne { + quo.mutation.SetBundleID(id) + return quo } // SetNillableBundleID sets the "bundle" edge to the File entity by ID if the given value is not nil. -func (juo *JobUpdateOne) SetNillableBundleID(id *int) *JobUpdateOne { +func (quo *QuestUpdateOne) SetNillableBundleID(id *int) *QuestUpdateOne { if id != nil { - juo = juo.SetBundleID(*id) + quo = quo.SetBundleID(*id) } - return juo + return quo } // SetBundle sets the "bundle" edge to the File entity. -func (juo *JobUpdateOne) SetBundle(f *File) *JobUpdateOne { - return juo.SetBundleID(f.ID) +func (quo *QuestUpdateOne) SetBundle(f *File) *QuestUpdateOne { + return quo.SetBundleID(f.ID) } // AddTaskIDs adds the "tasks" edge to the Task entity by IDs. -func (juo *JobUpdateOne) AddTaskIDs(ids ...int) *JobUpdateOne { - juo.mutation.AddTaskIDs(ids...) - return juo +func (quo *QuestUpdateOne) AddTaskIDs(ids ...int) *QuestUpdateOne { + quo.mutation.AddTaskIDs(ids...) + return quo } // AddTasks adds the "tasks" edges to the Task entity. -func (juo *JobUpdateOne) AddTasks(t ...*Task) *JobUpdateOne { +func (quo *QuestUpdateOne) AddTasks(t ...*Task) *QuestUpdateOne { ids := make([]int, len(t)) for i := range t { ids[i] = t[i].ID } - return juo.AddTaskIDs(ids...) + return quo.AddTaskIDs(ids...) } // SetCreatorID sets the "creator" edge to the User entity by ID. -func (juo *JobUpdateOne) SetCreatorID(id int) *JobUpdateOne { - juo.mutation.SetCreatorID(id) - return juo +func (quo *QuestUpdateOne) SetCreatorID(id int) *QuestUpdateOne { + quo.mutation.SetCreatorID(id) + return quo } // SetNillableCreatorID sets the "creator" edge to the User entity by ID if the given value is not nil. -func (juo *JobUpdateOne) SetNillableCreatorID(id *int) *JobUpdateOne { +func (quo *QuestUpdateOne) SetNillableCreatorID(id *int) *QuestUpdateOne { if id != nil { - juo = juo.SetCreatorID(*id) + quo = quo.SetCreatorID(*id) } - return juo + return quo } // SetCreator sets the "creator" edge to the User entity. -func (juo *JobUpdateOne) SetCreator(u *User) *JobUpdateOne { - return juo.SetCreatorID(u.ID) +func (quo *QuestUpdateOne) SetCreator(u *User) *QuestUpdateOne { + return quo.SetCreatorID(u.ID) } -// Mutation returns the JobMutation object of the builder. -func (juo *JobUpdateOne) Mutation() *JobMutation { - return juo.mutation +// Mutation returns the QuestMutation object of the builder. +func (quo *QuestUpdateOne) Mutation() *QuestMutation { + return quo.mutation } // ClearTome clears the "tome" edge to the Tome entity. -func (juo *JobUpdateOne) ClearTome() *JobUpdateOne { - juo.mutation.ClearTome() - return juo +func (quo *QuestUpdateOne) ClearTome() *QuestUpdateOne { + quo.mutation.ClearTome() + return quo } // ClearBundle clears the "bundle" edge to the File entity. -func (juo *JobUpdateOne) ClearBundle() *JobUpdateOne { - juo.mutation.ClearBundle() - return juo +func (quo *QuestUpdateOne) ClearBundle() *QuestUpdateOne { + quo.mutation.ClearBundle() + return quo } // ClearTasks clears all "tasks" edges to the Task entity. -func (juo *JobUpdateOne) ClearTasks() *JobUpdateOne { - juo.mutation.ClearTasks() - return juo +func (quo *QuestUpdateOne) ClearTasks() *QuestUpdateOne { + quo.mutation.ClearTasks() + return quo } // RemoveTaskIDs removes the "tasks" edge to Task entities by IDs. -func (juo *JobUpdateOne) RemoveTaskIDs(ids ...int) *JobUpdateOne { - juo.mutation.RemoveTaskIDs(ids...) - return juo +func (quo *QuestUpdateOne) RemoveTaskIDs(ids ...int) *QuestUpdateOne { + quo.mutation.RemoveTaskIDs(ids...) + return quo } // RemoveTasks removes "tasks" edges to Task entities. -func (juo *JobUpdateOne) RemoveTasks(t ...*Task) *JobUpdateOne { +func (quo *QuestUpdateOne) RemoveTasks(t ...*Task) *QuestUpdateOne { ids := make([]int, len(t)) for i := range t { ids[i] = t[i].ID } - return juo.RemoveTaskIDs(ids...) + return quo.RemoveTaskIDs(ids...) } // ClearCreator clears the "creator" edge to the User entity. -func (juo *JobUpdateOne) ClearCreator() *JobUpdateOne { - juo.mutation.ClearCreator() - return juo +func (quo *QuestUpdateOne) ClearCreator() *QuestUpdateOne { + quo.mutation.ClearCreator() + return quo } -// Where appends a list predicates to the JobUpdate builder. -func (juo *JobUpdateOne) Where(ps ...predicate.Job) *JobUpdateOne { - juo.mutation.Where(ps...) - return juo +// Where appends a list predicates to the QuestUpdate builder. +func (quo *QuestUpdateOne) Where(ps ...predicate.Quest) *QuestUpdateOne { + quo.mutation.Where(ps...) + return quo } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (juo *JobUpdateOne) Select(field string, fields ...string) *JobUpdateOne { - juo.fields = append([]string{field}, fields...) - return juo +func (quo *QuestUpdateOne) Select(field string, fields ...string) *QuestUpdateOne { + quo.fields = append([]string{field}, fields...) + return quo } -// Save executes the query and returns the updated Job entity. -func (juo *JobUpdateOne) Save(ctx context.Context) (*Job, error) { - juo.defaults() - return withHooks[*Job, JobMutation](ctx, juo.sqlSave, juo.mutation, juo.hooks) +// Save executes the query and returns the updated Quest entity. +func (quo *QuestUpdateOne) Save(ctx context.Context) (*Quest, error) { + quo.defaults() + return withHooks[*Quest, QuestMutation](ctx, quo.sqlSave, quo.mutation, quo.hooks) } // SaveX is like Save, but panics if an error occurs. -func (juo *JobUpdateOne) SaveX(ctx context.Context) *Job { - node, err := juo.Save(ctx) +func (quo *QuestUpdateOne) SaveX(ctx context.Context) *Quest { + node, err := quo.Save(ctx) if err != nil { panic(err) } @@ -593,86 +593,86 @@ func (juo *JobUpdateOne) SaveX(ctx context.Context) *Job { } // Exec executes the query on the entity. -func (juo *JobUpdateOne) Exec(ctx context.Context) error { - _, err := juo.Save(ctx) +func (quo *QuestUpdateOne) Exec(ctx context.Context) error { + _, err := quo.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (juo *JobUpdateOne) ExecX(ctx context.Context) { - if err := juo.Exec(ctx); err != nil { +func (quo *QuestUpdateOne) ExecX(ctx context.Context) { + if err := quo.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (juo *JobUpdateOne) defaults() { - if _, ok := juo.mutation.LastModifiedAt(); !ok { - v := job.UpdateDefaultLastModifiedAt() - juo.mutation.SetLastModifiedAt(v) +func (quo *QuestUpdateOne) defaults() { + if _, ok := quo.mutation.LastModifiedAt(); !ok { + v := quest.UpdateDefaultLastModifiedAt() + quo.mutation.SetLastModifiedAt(v) } } // check runs all checks and user-defined validators on the builder. -func (juo *JobUpdateOne) check() error { - if v, ok := juo.mutation.Name(); ok { - if err := job.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Job.name": %w`, err)} +func (quo *QuestUpdateOne) check() error { + if v, ok := quo.mutation.Name(); ok { + if err := quest.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Quest.name": %w`, err)} } } - if _, ok := juo.mutation.TomeID(); juo.mutation.TomeCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Job.tome"`) + if _, ok := quo.mutation.TomeID(); quo.mutation.TomeCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Quest.tome"`) } return nil } -func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { - if err := juo.check(); err != nil { +func (quo *QuestUpdateOne) sqlSave(ctx context.Context) (_node *Quest, err error) { + if err := quo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(job.Table, job.Columns, sqlgraph.NewFieldSpec(job.FieldID, field.TypeInt)) - id, ok := juo.mutation.ID() + _spec := sqlgraph.NewUpdateSpec(quest.Table, quest.Columns, sqlgraph.NewFieldSpec(quest.FieldID, field.TypeInt)) + id, ok := quo.mutation.ID() if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Job.id" for update`)} + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Quest.id" for update`)} } _spec.Node.ID.Value = id - if fields := juo.fields; len(fields) > 0 { + if fields := quo.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, job.FieldID) + _spec.Node.Columns = append(_spec.Node.Columns, quest.FieldID) for _, f := range fields { - if !job.ValidColumn(f) { + if !quest.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } - if f != job.FieldID { + if f != quest.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } - if ps := juo.mutation.predicates; len(ps) > 0 { + if ps := quo.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := juo.mutation.LastModifiedAt(); ok { - _spec.SetField(job.FieldLastModifiedAt, field.TypeTime, value) + if value, ok := quo.mutation.LastModifiedAt(); ok { + _spec.SetField(quest.FieldLastModifiedAt, field.TypeTime, value) } - if value, ok := juo.mutation.Name(); ok { - _spec.SetField(job.FieldName, field.TypeString, value) + if value, ok := quo.mutation.Name(); ok { + _spec.SetField(quest.FieldName, field.TypeString, value) } - if value, ok := juo.mutation.Parameters(); ok { - _spec.SetField(job.FieldParameters, field.TypeString, value) + if value, ok := quo.mutation.Parameters(); ok { + _spec.SetField(quest.FieldParameters, field.TypeString, value) } - if juo.mutation.ParametersCleared() { - _spec.ClearField(job.FieldParameters, field.TypeString) + if quo.mutation.ParametersCleared() { + _spec.ClearField(quest.FieldParameters, field.TypeString) } - if juo.mutation.TomeCleared() { + if quo.mutation.TomeCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.TomeTable, - Columns: []string{job.TomeColumn}, + Table: quest.TomeTable, + Columns: []string{quest.TomeColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -683,12 +683,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := juo.mutation.TomeIDs(); len(nodes) > 0 { + if nodes := quo.mutation.TomeIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.TomeTable, - Columns: []string{job.TomeColumn}, + Table: quest.TomeTable, + Columns: []string{quest.TomeColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -702,12 +702,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if juo.mutation.BundleCleared() { + if quo.mutation.BundleCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.BundleTable, - Columns: []string{job.BundleColumn}, + Table: quest.BundleTable, + Columns: []string{quest.BundleColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -718,12 +718,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := juo.mutation.BundleIDs(); len(nodes) > 0 { + if nodes := quo.mutation.BundleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.BundleTable, - Columns: []string{job.BundleColumn}, + Table: quest.BundleTable, + Columns: []string{quest.BundleColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -737,12 +737,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if juo.mutation.TasksCleared() { + if quo.mutation.TasksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: job.TasksTable, - Columns: []string{job.TasksColumn}, + Table: quest.TasksTable, + Columns: []string{quest.TasksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -753,12 +753,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := juo.mutation.RemovedTasksIDs(); len(nodes) > 0 && !juo.mutation.TasksCleared() { + if nodes := quo.mutation.RemovedTasksIDs(); len(nodes) > 0 && !quo.mutation.TasksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: job.TasksTable, - Columns: []string{job.TasksColumn}, + Table: quest.TasksTable, + Columns: []string{quest.TasksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -772,12 +772,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := juo.mutation.TasksIDs(); len(nodes) > 0 { + if nodes := quo.mutation.TasksIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: job.TasksTable, - Columns: []string{job.TasksColumn}, + Table: quest.TasksTable, + Columns: []string{quest.TasksColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -791,12 +791,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if juo.mutation.CreatorCleared() { + if quo.mutation.CreatorCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.CreatorTable, - Columns: []string{job.CreatorColumn}, + Table: quest.CreatorTable, + Columns: []string{quest.CreatorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -807,12 +807,12 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := juo.mutation.CreatorIDs(); len(nodes) > 0 { + if nodes := quo.mutation.CreatorIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: job.CreatorTable, - Columns: []string{job.CreatorColumn}, + Table: quest.CreatorTable, + Columns: []string{quest.CreatorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ @@ -826,17 +826,17 @@ func (juo *JobUpdateOne) sqlSave(ctx context.Context) (_node *Job, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _node = &Job{config: juo.config} + _node = &Quest{config: quo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, juo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, quo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{job.Label} + err = &NotFoundError{quest.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } - juo.mutation.done = true + quo.mutation.done = true return _node, nil } diff --git a/tavern/ent/runtime/runtime.go b/tavern/ent/runtime/runtime.go index 6fef4d77b..b53cfa6ad 100644 --- a/tavern/ent/runtime/runtime.go +++ b/tavern/ent/runtime/runtime.go @@ -5,10 +5,10 @@ package runtime import ( "time" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/job" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/schema" - "github.com/kcarretto/realm/tavern/ent/session" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/ent/tome" @@ -19,6 +19,36 @@ import ( // (default values, validators, hooks and policies) and stitches it // to their package variables. func init() { + beaconFields := schema.Beacon{}.Fields() + _ = beaconFields + // beaconDescName is the schema descriptor for name field. + beaconDescName := beaconFields[0].Descriptor() + // beacon.DefaultName holds the default value on creation for the name field. + beacon.DefaultName = beaconDescName.Default.(func() string) + // beacon.NameValidator is a validator for the "name" field. It is called by the builders before save. + beacon.NameValidator = beaconDescName.Validators[0].(func(string) error) + // beaconDescPrincipal is the schema descriptor for principal field. + beaconDescPrincipal := beaconFields[1].Descriptor() + // beacon.PrincipalValidator is a validator for the "principal" field. It is called by the builders before save. + beacon.PrincipalValidator = beaconDescPrincipal.Validators[0].(func(string) error) + // beaconDescHostname is the schema descriptor for hostname field. + beaconDescHostname := beaconFields[2].Descriptor() + // beacon.HostnameValidator is a validator for the "hostname" field. It is called by the builders before save. + beacon.HostnameValidator = beaconDescHostname.Validators[0].(func(string) error) + // beaconDescIdentifier is the schema descriptor for identifier field. + beaconDescIdentifier := beaconFields[3].Descriptor() + // beacon.DefaultIdentifier holds the default value on creation for the identifier field. + beacon.DefaultIdentifier = beaconDescIdentifier.Default.(func() string) + // beacon.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + beacon.IdentifierValidator = beaconDescIdentifier.Validators[0].(func(string) error) + // beaconDescAgentIdentifier is the schema descriptor for agent_identifier field. + beaconDescAgentIdentifier := beaconFields[4].Descriptor() + // beacon.AgentIdentifierValidator is a validator for the "agent_identifier" field. It is called by the builders before save. + beacon.AgentIdentifierValidator = beaconDescAgentIdentifier.Validators[0].(func(string) error) + // beaconDescHostIdentifier is the schema descriptor for host_identifier field. + beaconDescHostIdentifier := beaconFields[5].Descriptor() + // beacon.HostIdentifierValidator is a validator for the "host_identifier" field. It is called by the builders before save. + beacon.HostIdentifierValidator = beaconDescHostIdentifier.Validators[0].(func(string) error) fileMixin := schema.File{}.Mixin() fileHooks := schema.File{}.Hooks() file.Hooks[0] = fileHooks[0] @@ -50,55 +80,25 @@ func init() { fileDescHash := fileFields[2].Descriptor() // file.HashValidator is a validator for the "hash" field. It is called by the builders before save. file.HashValidator = fileDescHash.Validators[0].(func(string) error) - jobMixin := schema.Job{}.Mixin() - jobMixinFields0 := jobMixin[0].Fields() - _ = jobMixinFields0 - jobFields := schema.Job{}.Fields() - _ = jobFields - // jobDescCreatedAt is the schema descriptor for created_at field. - jobDescCreatedAt := jobMixinFields0[0].Descriptor() - // job.DefaultCreatedAt holds the default value on creation for the created_at field. - job.DefaultCreatedAt = jobDescCreatedAt.Default.(func() time.Time) - // jobDescLastModifiedAt is the schema descriptor for last_modified_at field. - jobDescLastModifiedAt := jobMixinFields0[1].Descriptor() - // job.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. - job.DefaultLastModifiedAt = jobDescLastModifiedAt.Default.(func() time.Time) - // job.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. - job.UpdateDefaultLastModifiedAt = jobDescLastModifiedAt.UpdateDefault.(func() time.Time) - // jobDescName is the schema descriptor for name field. - jobDescName := jobFields[0].Descriptor() - // job.NameValidator is a validator for the "name" field. It is called by the builders before save. - job.NameValidator = jobDescName.Validators[0].(func(string) error) - sessionFields := schema.Session{}.Fields() - _ = sessionFields - // sessionDescName is the schema descriptor for name field. - sessionDescName := sessionFields[0].Descriptor() - // session.DefaultName holds the default value on creation for the name field. - session.DefaultName = sessionDescName.Default.(func() string) - // session.NameValidator is a validator for the "name" field. It is called by the builders before save. - session.NameValidator = sessionDescName.Validators[0].(func(string) error) - // sessionDescPrincipal is the schema descriptor for principal field. - sessionDescPrincipal := sessionFields[1].Descriptor() - // session.PrincipalValidator is a validator for the "principal" field. It is called by the builders before save. - session.PrincipalValidator = sessionDescPrincipal.Validators[0].(func(string) error) - // sessionDescHostname is the schema descriptor for hostname field. - sessionDescHostname := sessionFields[2].Descriptor() - // session.HostnameValidator is a validator for the "hostname" field. It is called by the builders before save. - session.HostnameValidator = sessionDescHostname.Validators[0].(func(string) error) - // sessionDescIdentifier is the schema descriptor for identifier field. - sessionDescIdentifier := sessionFields[3].Descriptor() - // session.DefaultIdentifier holds the default value on creation for the identifier field. - session.DefaultIdentifier = sessionDescIdentifier.Default.(func() string) - // session.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. - session.IdentifierValidator = sessionDescIdentifier.Validators[0].(func(string) error) - // sessionDescAgentIdentifier is the schema descriptor for agent_identifier field. - sessionDescAgentIdentifier := sessionFields[4].Descriptor() - // session.AgentIdentifierValidator is a validator for the "agent_identifier" field. It is called by the builders before save. - session.AgentIdentifierValidator = sessionDescAgentIdentifier.Validators[0].(func(string) error) - // sessionDescHostIdentifier is the schema descriptor for host_identifier field. - sessionDescHostIdentifier := sessionFields[5].Descriptor() - // session.HostIdentifierValidator is a validator for the "host_identifier" field. It is called by the builders before save. - session.HostIdentifierValidator = sessionDescHostIdentifier.Validators[0].(func(string) error) + questMixin := schema.Quest{}.Mixin() + questMixinFields0 := questMixin[0].Fields() + _ = questMixinFields0 + questFields := schema.Quest{}.Fields() + _ = questFields + // questDescCreatedAt is the schema descriptor for created_at field. + questDescCreatedAt := questMixinFields0[0].Descriptor() + // quest.DefaultCreatedAt holds the default value on creation for the created_at field. + quest.DefaultCreatedAt = questDescCreatedAt.Default.(func() time.Time) + // questDescLastModifiedAt is the schema descriptor for last_modified_at field. + questDescLastModifiedAt := questMixinFields0[1].Descriptor() + // quest.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + quest.DefaultLastModifiedAt = questDescLastModifiedAt.Default.(func() time.Time) + // quest.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + quest.UpdateDefaultLastModifiedAt = questDescLastModifiedAt.UpdateDefault.(func() time.Time) + // questDescName is the schema descriptor for name field. + questDescName := questFields[0].Descriptor() + // quest.NameValidator is a validator for the "name" field. It is called by the builders before save. + quest.NameValidator = questDescName.Validators[0].(func(string) error) tagFields := schema.Tag{}.Fields() _ = tagFields // tagDescName is the schema descriptor for name field. diff --git a/tavern/ent/schema/session.go b/tavern/ent/schema/beacon.go similarity index 71% rename from tavern/ent/schema/session.go rename to tavern/ent/schema/beacon.go index 34fbd9798..c62191af4 100644 --- a/tavern/ent/schema/session.go +++ b/tavern/ent/schema/beacon.go @@ -15,30 +15,30 @@ import ( "entgo.io/ent/schema/field" ) -// Session holds the schema definition for the Session entity. -type Session struct { +// Beacon holds the schema definition for the Beacon entity. +type Beacon struct { ent.Schema } -// Fields of the Session. -func (Session) Fields() []ent.Field { +// Fields of the Beacon. +func (Beacon) Fields() []ent.Field { return []ent.Field{ field.String("name"). NotEmpty(). Unique(). DefaultFunc(namegen.GetRandomName). - Comment("A human readable identifier for the session."), + Comment("A human readable identifier for the beacon."), field.String("principal"). Optional(). NotEmpty(). Annotations( entgql.Skip(entgql.SkipMutationUpdateInput), ). - Comment("The identity the session is authenticated as (e.g. 'root')"), + Comment("The identity the beacon is authenticated as (e.g. 'root')"), field.String("hostname"). Optional(). NotEmpty(). - Comment("The hostname of the system the session is running on."), + Comment("The hostname of the system the beacon is running on."), field.String("identifier"). DefaultFunc(newRandomIdentifier). NotEmpty(). @@ -46,21 +46,21 @@ func (Session) Fields() []ent.Field { Annotations( entgql.Skip(entgql.SkipMutationUpdateInput), ). - Comment("Unique identifier for the session. Unique to each instance of the session."), + Comment("Unique identifier for the beacon. Unique to each instance of the beacon."), field.String("agent_identifier"). Optional(). NotEmpty(). Annotations( entgql.Skip(entgql.SkipMutationUpdateInput), ). - Comment("Identifies the agent that the session is running as (e.g. 'imix')."), + Comment("Identifies the agent that the beacon is running as (e.g. 'imix')."), field.String("host_identifier"). Optional(). NotEmpty(). Annotations( entgql.Skip(entgql.SkipMutationUpdateInput), ). - Comment("Unique identifier for the host the session is running on."), + Comment("Unique identifier for the host the beacon is running on."), field.String("host_primary_ip"). Optional(). Annotations( @@ -80,26 +80,26 @@ func (Session) Fields() []ent.Field { entgql.OrderField("LAST_SEEN_AT"), entgql.Skip(entgql.SkipMutationUpdateInput), ). - Comment("Timestamp of when a task was last claimed or updated for a target"), + Comment("Timestamp of when a task was last claimed or updated for the beacon."), } } -// Edges of the Target. -func (Session) Edges() []ent.Edge { +// Edges of the Beacon. +func (Beacon) Edges() []ent.Edge { return []ent.Edge{ edge.To("tags", Tag.Type). - Comment("Tags used to group the session with other sessions"), + Comment("Tags used to group this beacon with other beacons."), edge.From("tasks", Task.Type). Annotations( entgql.Skip(entgql.SkipMutationUpdateInput), ). - Ref("session"). - Comment("Tasks that have been assigned to the session"), + Ref("beacon"). + Comment("Tasks that have been assigned to the beacon."), } } // Annotations describes additional information for the ent. -func (Session) Annotations() []schema.Annotation { +func (Beacon) Annotations() []schema.Annotation { return []schema.Annotation{ entgql.Mutations( entgql.MutationUpdate(), diff --git a/tavern/ent/schema/job.go b/tavern/ent/schema/quest.go similarity index 69% rename from tavern/ent/schema/job.go rename to tavern/ent/schema/quest.go index d82af7b06..cb44eaab5 100644 --- a/tavern/ent/schema/job.go +++ b/tavern/ent/schema/quest.go @@ -8,31 +8,31 @@ import ( "entgo.io/ent/schema/field" ) -// Job holds the schema definition for the Job entity. -type Job struct { +// Quest holds the schema definition for the Quest entity. +type Quest struct { ent.Schema } -// Fields of the Job. -func (Job) Fields() []ent.Field { +// Fields of the Quest. +func (Quest) Fields() []ent.Field { return []ent.Field{ field.String("name"). NotEmpty(). Annotations( entgql.OrderField("NAME"), ). - Comment("Name of the job"), + Comment("Name of the quest"), field.String("parameters"). Optional(). - Comment("Value of parameters that were specified for the job (as a JSON string)."), + Comment("Value of parameters that were specified for the quest (as a JSON string)."), } } -// Edges of the Job. -func (Job) Edges() []ent.Edge { +// Edges of the Quest. +func (Quest) Edges() []ent.Edge { return []ent.Edge{ edge.To("tome", Tome.Type). - Comment("Tome that this job will be executing"). + Comment("Tome that this quest will be executing"). Required(). Unique(), edge.To("bundle", File.Type). @@ -51,12 +51,12 @@ func (Job) Edges() []ent.Edge { Annotations( entgql.Skip(entgql.SkipMutationCreateInput), ). - Comment("User that created the job if available."), + Comment("User that created the quest if available."), } } // Annotations describes additional information for the ent. -func (Job) Annotations() []schema.Annotation { +func (Quest) Annotations() []schema.Annotation { return []schema.Annotation{ entgql.Mutations( entgql.MutationCreate(), @@ -65,7 +65,7 @@ func (Job) Annotations() []schema.Annotation { } // Mixin defines common shared properties for the ent. -func (Job) Mixin() []ent.Mixin { +func (Quest) Mixin() []ent.Mixin { return []ent.Mixin{ MixinHistory{}, // created_at, last_modified_at } diff --git a/tavern/ent/schema/tag.go b/tavern/ent/schema/tag.go index d79e15ad0..d5ca82009 100644 --- a/tavern/ent/schema/tag.go +++ b/tavern/ent/schema/tag.go @@ -32,7 +32,7 @@ func (Tag) Fields() []ent.Field { // Edges of the Tag. func (Tag) Edges() []ent.Edge { return []ent.Edge{ - edge.From("sessions", Session.Type). + edge.From("beacons", Beacon.Type). Ref("tags"), } } diff --git a/tavern/ent/schema/task.go b/tavern/ent/schema/task.go index 416fa6d9b..456140d99 100644 --- a/tavern/ent/schema/task.go +++ b/tavern/ent/schema/task.go @@ -45,11 +45,11 @@ func (Task) Fields() []ent.Field { // Edges of the Task. func (Task) Edges() []ent.Edge { return []ent.Edge{ - edge.From("job", Job.Type). + edge.From("quest", Quest.Type). Ref("tasks"). Required(). Unique(), - edge.To("session", Session.Type). + edge.To("beacon", Beacon.Type). Required(). Unique(), } diff --git a/tavern/ent/session/where.go b/tavern/ent/session/where.go deleted file mode 100644 index aa5401ad1..000000000 --- a/tavern/ent/session/where.go +++ /dev/null @@ -1,757 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package session - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/kcarretto/realm/tavern/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Session { - return predicate.Session(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Session { - return predicate.Session(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Session { - return predicate.Session(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldID, id)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldName, v)) -} - -// Principal applies equality check predicate on the "principal" field. It's identical to PrincipalEQ. -func Principal(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldPrincipal, v)) -} - -// Hostname applies equality check predicate on the "hostname" field. It's identical to HostnameEQ. -func Hostname(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldHostname, v)) -} - -// Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. -func Identifier(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldIdentifier, v)) -} - -// AgentIdentifier applies equality check predicate on the "agent_identifier" field. It's identical to AgentIdentifierEQ. -func AgentIdentifier(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldAgentIdentifier, v)) -} - -// HostIdentifier applies equality check predicate on the "host_identifier" field. It's identical to HostIdentifierEQ. -func HostIdentifier(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldHostIdentifier, v)) -} - -// HostPrimaryIP applies equality check predicate on the "host_primary_ip" field. It's identical to HostPrimaryIPEQ. -func HostPrimaryIP(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldHostPrimaryIP, v)) -} - -// LastSeenAt applies equality check predicate on the "last_seen_at" field. It's identical to LastSeenAtEQ. -func LastSeenAt(v time.Time) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldLastSeenAt, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Session { - return predicate.Session(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Session { - return predicate.Session(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Session { - return predicate.Session(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Session { - return predicate.Session(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Session { - return predicate.Session(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Session { - return predicate.Session(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Session { - return predicate.Session(sql.FieldContainsFold(FieldName, v)) -} - -// PrincipalEQ applies the EQ predicate on the "principal" field. -func PrincipalEQ(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldPrincipal, v)) -} - -// PrincipalNEQ applies the NEQ predicate on the "principal" field. -func PrincipalNEQ(v string) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldPrincipal, v)) -} - -// PrincipalIn applies the In predicate on the "principal" field. -func PrincipalIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldIn(FieldPrincipal, vs...)) -} - -// PrincipalNotIn applies the NotIn predicate on the "principal" field. -func PrincipalNotIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldPrincipal, vs...)) -} - -// PrincipalGT applies the GT predicate on the "principal" field. -func PrincipalGT(v string) predicate.Session { - return predicate.Session(sql.FieldGT(FieldPrincipal, v)) -} - -// PrincipalGTE applies the GTE predicate on the "principal" field. -func PrincipalGTE(v string) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldPrincipal, v)) -} - -// PrincipalLT applies the LT predicate on the "principal" field. -func PrincipalLT(v string) predicate.Session { - return predicate.Session(sql.FieldLT(FieldPrincipal, v)) -} - -// PrincipalLTE applies the LTE predicate on the "principal" field. -func PrincipalLTE(v string) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldPrincipal, v)) -} - -// PrincipalContains applies the Contains predicate on the "principal" field. -func PrincipalContains(v string) predicate.Session { - return predicate.Session(sql.FieldContains(FieldPrincipal, v)) -} - -// PrincipalHasPrefix applies the HasPrefix predicate on the "principal" field. -func PrincipalHasPrefix(v string) predicate.Session { - return predicate.Session(sql.FieldHasPrefix(FieldPrincipal, v)) -} - -// PrincipalHasSuffix applies the HasSuffix predicate on the "principal" field. -func PrincipalHasSuffix(v string) predicate.Session { - return predicate.Session(sql.FieldHasSuffix(FieldPrincipal, v)) -} - -// PrincipalIsNil applies the IsNil predicate on the "principal" field. -func PrincipalIsNil() predicate.Session { - return predicate.Session(sql.FieldIsNull(FieldPrincipal)) -} - -// PrincipalNotNil applies the NotNil predicate on the "principal" field. -func PrincipalNotNil() predicate.Session { - return predicate.Session(sql.FieldNotNull(FieldPrincipal)) -} - -// PrincipalEqualFold applies the EqualFold predicate on the "principal" field. -func PrincipalEqualFold(v string) predicate.Session { - return predicate.Session(sql.FieldEqualFold(FieldPrincipal, v)) -} - -// PrincipalContainsFold applies the ContainsFold predicate on the "principal" field. -func PrincipalContainsFold(v string) predicate.Session { - return predicate.Session(sql.FieldContainsFold(FieldPrincipal, v)) -} - -// HostnameEQ applies the EQ predicate on the "hostname" field. -func HostnameEQ(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldHostname, v)) -} - -// HostnameNEQ applies the NEQ predicate on the "hostname" field. -func HostnameNEQ(v string) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldHostname, v)) -} - -// HostnameIn applies the In predicate on the "hostname" field. -func HostnameIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldIn(FieldHostname, vs...)) -} - -// HostnameNotIn applies the NotIn predicate on the "hostname" field. -func HostnameNotIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldHostname, vs...)) -} - -// HostnameGT applies the GT predicate on the "hostname" field. -func HostnameGT(v string) predicate.Session { - return predicate.Session(sql.FieldGT(FieldHostname, v)) -} - -// HostnameGTE applies the GTE predicate on the "hostname" field. -func HostnameGTE(v string) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldHostname, v)) -} - -// HostnameLT applies the LT predicate on the "hostname" field. -func HostnameLT(v string) predicate.Session { - return predicate.Session(sql.FieldLT(FieldHostname, v)) -} - -// HostnameLTE applies the LTE predicate on the "hostname" field. -func HostnameLTE(v string) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldHostname, v)) -} - -// HostnameContains applies the Contains predicate on the "hostname" field. -func HostnameContains(v string) predicate.Session { - return predicate.Session(sql.FieldContains(FieldHostname, v)) -} - -// HostnameHasPrefix applies the HasPrefix predicate on the "hostname" field. -func HostnameHasPrefix(v string) predicate.Session { - return predicate.Session(sql.FieldHasPrefix(FieldHostname, v)) -} - -// HostnameHasSuffix applies the HasSuffix predicate on the "hostname" field. -func HostnameHasSuffix(v string) predicate.Session { - return predicate.Session(sql.FieldHasSuffix(FieldHostname, v)) -} - -// HostnameIsNil applies the IsNil predicate on the "hostname" field. -func HostnameIsNil() predicate.Session { - return predicate.Session(sql.FieldIsNull(FieldHostname)) -} - -// HostnameNotNil applies the NotNil predicate on the "hostname" field. -func HostnameNotNil() predicate.Session { - return predicate.Session(sql.FieldNotNull(FieldHostname)) -} - -// HostnameEqualFold applies the EqualFold predicate on the "hostname" field. -func HostnameEqualFold(v string) predicate.Session { - return predicate.Session(sql.FieldEqualFold(FieldHostname, v)) -} - -// HostnameContainsFold applies the ContainsFold predicate on the "hostname" field. -func HostnameContainsFold(v string) predicate.Session { - return predicate.Session(sql.FieldContainsFold(FieldHostname, v)) -} - -// IdentifierEQ applies the EQ predicate on the "identifier" field. -func IdentifierEQ(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldIdentifier, v)) -} - -// IdentifierNEQ applies the NEQ predicate on the "identifier" field. -func IdentifierNEQ(v string) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldIdentifier, v)) -} - -// IdentifierIn applies the In predicate on the "identifier" field. -func IdentifierIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldIn(FieldIdentifier, vs...)) -} - -// IdentifierNotIn applies the NotIn predicate on the "identifier" field. -func IdentifierNotIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldIdentifier, vs...)) -} - -// IdentifierGT applies the GT predicate on the "identifier" field. -func IdentifierGT(v string) predicate.Session { - return predicate.Session(sql.FieldGT(FieldIdentifier, v)) -} - -// IdentifierGTE applies the GTE predicate on the "identifier" field. -func IdentifierGTE(v string) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldIdentifier, v)) -} - -// IdentifierLT applies the LT predicate on the "identifier" field. -func IdentifierLT(v string) predicate.Session { - return predicate.Session(sql.FieldLT(FieldIdentifier, v)) -} - -// IdentifierLTE applies the LTE predicate on the "identifier" field. -func IdentifierLTE(v string) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldIdentifier, v)) -} - -// IdentifierContains applies the Contains predicate on the "identifier" field. -func IdentifierContains(v string) predicate.Session { - return predicate.Session(sql.FieldContains(FieldIdentifier, v)) -} - -// IdentifierHasPrefix applies the HasPrefix predicate on the "identifier" field. -func IdentifierHasPrefix(v string) predicate.Session { - return predicate.Session(sql.FieldHasPrefix(FieldIdentifier, v)) -} - -// IdentifierHasSuffix applies the HasSuffix predicate on the "identifier" field. -func IdentifierHasSuffix(v string) predicate.Session { - return predicate.Session(sql.FieldHasSuffix(FieldIdentifier, v)) -} - -// IdentifierEqualFold applies the EqualFold predicate on the "identifier" field. -func IdentifierEqualFold(v string) predicate.Session { - return predicate.Session(sql.FieldEqualFold(FieldIdentifier, v)) -} - -// IdentifierContainsFold applies the ContainsFold predicate on the "identifier" field. -func IdentifierContainsFold(v string) predicate.Session { - return predicate.Session(sql.FieldContainsFold(FieldIdentifier, v)) -} - -// AgentIdentifierEQ applies the EQ predicate on the "agent_identifier" field. -func AgentIdentifierEQ(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldAgentIdentifier, v)) -} - -// AgentIdentifierNEQ applies the NEQ predicate on the "agent_identifier" field. -func AgentIdentifierNEQ(v string) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldAgentIdentifier, v)) -} - -// AgentIdentifierIn applies the In predicate on the "agent_identifier" field. -func AgentIdentifierIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldIn(FieldAgentIdentifier, vs...)) -} - -// AgentIdentifierNotIn applies the NotIn predicate on the "agent_identifier" field. -func AgentIdentifierNotIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldAgentIdentifier, vs...)) -} - -// AgentIdentifierGT applies the GT predicate on the "agent_identifier" field. -func AgentIdentifierGT(v string) predicate.Session { - return predicate.Session(sql.FieldGT(FieldAgentIdentifier, v)) -} - -// AgentIdentifierGTE applies the GTE predicate on the "agent_identifier" field. -func AgentIdentifierGTE(v string) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldAgentIdentifier, v)) -} - -// AgentIdentifierLT applies the LT predicate on the "agent_identifier" field. -func AgentIdentifierLT(v string) predicate.Session { - return predicate.Session(sql.FieldLT(FieldAgentIdentifier, v)) -} - -// AgentIdentifierLTE applies the LTE predicate on the "agent_identifier" field. -func AgentIdentifierLTE(v string) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldAgentIdentifier, v)) -} - -// AgentIdentifierContains applies the Contains predicate on the "agent_identifier" field. -func AgentIdentifierContains(v string) predicate.Session { - return predicate.Session(sql.FieldContains(FieldAgentIdentifier, v)) -} - -// AgentIdentifierHasPrefix applies the HasPrefix predicate on the "agent_identifier" field. -func AgentIdentifierHasPrefix(v string) predicate.Session { - return predicate.Session(sql.FieldHasPrefix(FieldAgentIdentifier, v)) -} - -// AgentIdentifierHasSuffix applies the HasSuffix predicate on the "agent_identifier" field. -func AgentIdentifierHasSuffix(v string) predicate.Session { - return predicate.Session(sql.FieldHasSuffix(FieldAgentIdentifier, v)) -} - -// AgentIdentifierIsNil applies the IsNil predicate on the "agent_identifier" field. -func AgentIdentifierIsNil() predicate.Session { - return predicate.Session(sql.FieldIsNull(FieldAgentIdentifier)) -} - -// AgentIdentifierNotNil applies the NotNil predicate on the "agent_identifier" field. -func AgentIdentifierNotNil() predicate.Session { - return predicate.Session(sql.FieldNotNull(FieldAgentIdentifier)) -} - -// AgentIdentifierEqualFold applies the EqualFold predicate on the "agent_identifier" field. -func AgentIdentifierEqualFold(v string) predicate.Session { - return predicate.Session(sql.FieldEqualFold(FieldAgentIdentifier, v)) -} - -// AgentIdentifierContainsFold applies the ContainsFold predicate on the "agent_identifier" field. -func AgentIdentifierContainsFold(v string) predicate.Session { - return predicate.Session(sql.FieldContainsFold(FieldAgentIdentifier, v)) -} - -// HostIdentifierEQ applies the EQ predicate on the "host_identifier" field. -func HostIdentifierEQ(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldHostIdentifier, v)) -} - -// HostIdentifierNEQ applies the NEQ predicate on the "host_identifier" field. -func HostIdentifierNEQ(v string) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldHostIdentifier, v)) -} - -// HostIdentifierIn applies the In predicate on the "host_identifier" field. -func HostIdentifierIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldIn(FieldHostIdentifier, vs...)) -} - -// HostIdentifierNotIn applies the NotIn predicate on the "host_identifier" field. -func HostIdentifierNotIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldHostIdentifier, vs...)) -} - -// HostIdentifierGT applies the GT predicate on the "host_identifier" field. -func HostIdentifierGT(v string) predicate.Session { - return predicate.Session(sql.FieldGT(FieldHostIdentifier, v)) -} - -// HostIdentifierGTE applies the GTE predicate on the "host_identifier" field. -func HostIdentifierGTE(v string) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldHostIdentifier, v)) -} - -// HostIdentifierLT applies the LT predicate on the "host_identifier" field. -func HostIdentifierLT(v string) predicate.Session { - return predicate.Session(sql.FieldLT(FieldHostIdentifier, v)) -} - -// HostIdentifierLTE applies the LTE predicate on the "host_identifier" field. -func HostIdentifierLTE(v string) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldHostIdentifier, v)) -} - -// HostIdentifierContains applies the Contains predicate on the "host_identifier" field. -func HostIdentifierContains(v string) predicate.Session { - return predicate.Session(sql.FieldContains(FieldHostIdentifier, v)) -} - -// HostIdentifierHasPrefix applies the HasPrefix predicate on the "host_identifier" field. -func HostIdentifierHasPrefix(v string) predicate.Session { - return predicate.Session(sql.FieldHasPrefix(FieldHostIdentifier, v)) -} - -// HostIdentifierHasSuffix applies the HasSuffix predicate on the "host_identifier" field. -func HostIdentifierHasSuffix(v string) predicate.Session { - return predicate.Session(sql.FieldHasSuffix(FieldHostIdentifier, v)) -} - -// HostIdentifierIsNil applies the IsNil predicate on the "host_identifier" field. -func HostIdentifierIsNil() predicate.Session { - return predicate.Session(sql.FieldIsNull(FieldHostIdentifier)) -} - -// HostIdentifierNotNil applies the NotNil predicate on the "host_identifier" field. -func HostIdentifierNotNil() predicate.Session { - return predicate.Session(sql.FieldNotNull(FieldHostIdentifier)) -} - -// HostIdentifierEqualFold applies the EqualFold predicate on the "host_identifier" field. -func HostIdentifierEqualFold(v string) predicate.Session { - return predicate.Session(sql.FieldEqualFold(FieldHostIdentifier, v)) -} - -// HostIdentifierContainsFold applies the ContainsFold predicate on the "host_identifier" field. -func HostIdentifierContainsFold(v string) predicate.Session { - return predicate.Session(sql.FieldContainsFold(FieldHostIdentifier, v)) -} - -// HostPrimaryIPEQ applies the EQ predicate on the "host_primary_ip" field. -func HostPrimaryIPEQ(v string) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPNEQ applies the NEQ predicate on the "host_primary_ip" field. -func HostPrimaryIPNEQ(v string) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPIn applies the In predicate on the "host_primary_ip" field. -func HostPrimaryIPIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldIn(FieldHostPrimaryIP, vs...)) -} - -// HostPrimaryIPNotIn applies the NotIn predicate on the "host_primary_ip" field. -func HostPrimaryIPNotIn(vs ...string) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldHostPrimaryIP, vs...)) -} - -// HostPrimaryIPGT applies the GT predicate on the "host_primary_ip" field. -func HostPrimaryIPGT(v string) predicate.Session { - return predicate.Session(sql.FieldGT(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPGTE applies the GTE predicate on the "host_primary_ip" field. -func HostPrimaryIPGTE(v string) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPLT applies the LT predicate on the "host_primary_ip" field. -func HostPrimaryIPLT(v string) predicate.Session { - return predicate.Session(sql.FieldLT(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPLTE applies the LTE predicate on the "host_primary_ip" field. -func HostPrimaryIPLTE(v string) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPContains applies the Contains predicate on the "host_primary_ip" field. -func HostPrimaryIPContains(v string) predicate.Session { - return predicate.Session(sql.FieldContains(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPHasPrefix applies the HasPrefix predicate on the "host_primary_ip" field. -func HostPrimaryIPHasPrefix(v string) predicate.Session { - return predicate.Session(sql.FieldHasPrefix(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPHasSuffix applies the HasSuffix predicate on the "host_primary_ip" field. -func HostPrimaryIPHasSuffix(v string) predicate.Session { - return predicate.Session(sql.FieldHasSuffix(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPIsNil applies the IsNil predicate on the "host_primary_ip" field. -func HostPrimaryIPIsNil() predicate.Session { - return predicate.Session(sql.FieldIsNull(FieldHostPrimaryIP)) -} - -// HostPrimaryIPNotNil applies the NotNil predicate on the "host_primary_ip" field. -func HostPrimaryIPNotNil() predicate.Session { - return predicate.Session(sql.FieldNotNull(FieldHostPrimaryIP)) -} - -// HostPrimaryIPEqualFold applies the EqualFold predicate on the "host_primary_ip" field. -func HostPrimaryIPEqualFold(v string) predicate.Session { - return predicate.Session(sql.FieldEqualFold(FieldHostPrimaryIP, v)) -} - -// HostPrimaryIPContainsFold applies the ContainsFold predicate on the "host_primary_ip" field. -func HostPrimaryIPContainsFold(v string) predicate.Session { - return predicate.Session(sql.FieldContainsFold(FieldHostPrimaryIP, v)) -} - -// HostPlatformEQ applies the EQ predicate on the "host_platform" field. -func HostPlatformEQ(v HostPlatform) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldHostPlatform, v)) -} - -// HostPlatformNEQ applies the NEQ predicate on the "host_platform" field. -func HostPlatformNEQ(v HostPlatform) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldHostPlatform, v)) -} - -// HostPlatformIn applies the In predicate on the "host_platform" field. -func HostPlatformIn(vs ...HostPlatform) predicate.Session { - return predicate.Session(sql.FieldIn(FieldHostPlatform, vs...)) -} - -// HostPlatformNotIn applies the NotIn predicate on the "host_platform" field. -func HostPlatformNotIn(vs ...HostPlatform) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldHostPlatform, vs...)) -} - -// LastSeenAtEQ applies the EQ predicate on the "last_seen_at" field. -func LastSeenAtEQ(v time.Time) predicate.Session { - return predicate.Session(sql.FieldEQ(FieldLastSeenAt, v)) -} - -// LastSeenAtNEQ applies the NEQ predicate on the "last_seen_at" field. -func LastSeenAtNEQ(v time.Time) predicate.Session { - return predicate.Session(sql.FieldNEQ(FieldLastSeenAt, v)) -} - -// LastSeenAtIn applies the In predicate on the "last_seen_at" field. -func LastSeenAtIn(vs ...time.Time) predicate.Session { - return predicate.Session(sql.FieldIn(FieldLastSeenAt, vs...)) -} - -// LastSeenAtNotIn applies the NotIn predicate on the "last_seen_at" field. -func LastSeenAtNotIn(vs ...time.Time) predicate.Session { - return predicate.Session(sql.FieldNotIn(FieldLastSeenAt, vs...)) -} - -// LastSeenAtGT applies the GT predicate on the "last_seen_at" field. -func LastSeenAtGT(v time.Time) predicate.Session { - return predicate.Session(sql.FieldGT(FieldLastSeenAt, v)) -} - -// LastSeenAtGTE applies the GTE predicate on the "last_seen_at" field. -func LastSeenAtGTE(v time.Time) predicate.Session { - return predicate.Session(sql.FieldGTE(FieldLastSeenAt, v)) -} - -// LastSeenAtLT applies the LT predicate on the "last_seen_at" field. -func LastSeenAtLT(v time.Time) predicate.Session { - return predicate.Session(sql.FieldLT(FieldLastSeenAt, v)) -} - -// LastSeenAtLTE applies the LTE predicate on the "last_seen_at" field. -func LastSeenAtLTE(v time.Time) predicate.Session { - return predicate.Session(sql.FieldLTE(FieldLastSeenAt, v)) -} - -// LastSeenAtIsNil applies the IsNil predicate on the "last_seen_at" field. -func LastSeenAtIsNil() predicate.Session { - return predicate.Session(sql.FieldIsNull(FieldLastSeenAt)) -} - -// LastSeenAtNotNil applies the NotNil predicate on the "last_seen_at" field. -func LastSeenAtNotNil() predicate.Session { - return predicate.Session(sql.FieldNotNull(FieldLastSeenAt)) -} - -// HasTags applies the HasEdge predicate on the "tags" edge. -func HasTags() predicate.Session { - return predicate.Session(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTagsWith applies the HasEdge predicate on the "tags" edge with a given conditions (other predicates). -func HasTagsWith(preds ...predicate.Tag) predicate.Session { - return predicate.Session(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TagsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasTasks applies the HasEdge predicate on the "tasks" edge. -func HasTasks() predicate.Session { - return predicate.Session(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TasksTable, TasksColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTasksWith applies the HasEdge predicate on the "tasks" edge with a given conditions (other predicates). -func HasTasksWith(preds ...predicate.Task) predicate.Session { - return predicate.Session(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TasksInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TasksTable, TasksColumn), - ) - 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.Session) predicate.Session { - return predicate.Session(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Session) predicate.Session { - return predicate.Session(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Session) predicate.Session { - return predicate.Session(func(s *sql.Selector) { - p(s.Not()) - }) -} diff --git a/tavern/ent/session_create.go b/tavern/ent/session_create.go deleted file mode 100644 index 6ce25fa36..000000000 --- a/tavern/ent/session_create.go +++ /dev/null @@ -1,461 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/session" - "github.com/kcarretto/realm/tavern/ent/tag" - "github.com/kcarretto/realm/tavern/ent/task" -) - -// SessionCreate is the builder for creating a Session entity. -type SessionCreate struct { - config - mutation *SessionMutation - hooks []Hook -} - -// SetName sets the "name" field. -func (sc *SessionCreate) SetName(s string) *SessionCreate { - sc.mutation.SetName(s) - return sc -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (sc *SessionCreate) SetNillableName(s *string) *SessionCreate { - if s != nil { - sc.SetName(*s) - } - return sc -} - -// SetPrincipal sets the "principal" field. -func (sc *SessionCreate) SetPrincipal(s string) *SessionCreate { - sc.mutation.SetPrincipal(s) - return sc -} - -// SetNillablePrincipal sets the "principal" field if the given value is not nil. -func (sc *SessionCreate) SetNillablePrincipal(s *string) *SessionCreate { - if s != nil { - sc.SetPrincipal(*s) - } - return sc -} - -// SetHostname sets the "hostname" field. -func (sc *SessionCreate) SetHostname(s string) *SessionCreate { - sc.mutation.SetHostname(s) - return sc -} - -// SetNillableHostname sets the "hostname" field if the given value is not nil. -func (sc *SessionCreate) SetNillableHostname(s *string) *SessionCreate { - if s != nil { - sc.SetHostname(*s) - } - return sc -} - -// SetIdentifier sets the "identifier" field. -func (sc *SessionCreate) SetIdentifier(s string) *SessionCreate { - sc.mutation.SetIdentifier(s) - return sc -} - -// SetNillableIdentifier sets the "identifier" field if the given value is not nil. -func (sc *SessionCreate) SetNillableIdentifier(s *string) *SessionCreate { - if s != nil { - sc.SetIdentifier(*s) - } - return sc -} - -// SetAgentIdentifier sets the "agent_identifier" field. -func (sc *SessionCreate) SetAgentIdentifier(s string) *SessionCreate { - sc.mutation.SetAgentIdentifier(s) - return sc -} - -// SetNillableAgentIdentifier sets the "agent_identifier" field if the given value is not nil. -func (sc *SessionCreate) SetNillableAgentIdentifier(s *string) *SessionCreate { - if s != nil { - sc.SetAgentIdentifier(*s) - } - return sc -} - -// SetHostIdentifier sets the "host_identifier" field. -func (sc *SessionCreate) SetHostIdentifier(s string) *SessionCreate { - sc.mutation.SetHostIdentifier(s) - return sc -} - -// SetNillableHostIdentifier sets the "host_identifier" field if the given value is not nil. -func (sc *SessionCreate) SetNillableHostIdentifier(s *string) *SessionCreate { - if s != nil { - sc.SetHostIdentifier(*s) - } - return sc -} - -// SetHostPrimaryIP sets the "host_primary_ip" field. -func (sc *SessionCreate) SetHostPrimaryIP(s string) *SessionCreate { - sc.mutation.SetHostPrimaryIP(s) - return sc -} - -// SetNillableHostPrimaryIP sets the "host_primary_ip" field if the given value is not nil. -func (sc *SessionCreate) SetNillableHostPrimaryIP(s *string) *SessionCreate { - if s != nil { - sc.SetHostPrimaryIP(*s) - } - return sc -} - -// SetHostPlatform sets the "host_platform" field. -func (sc *SessionCreate) SetHostPlatform(sp session.HostPlatform) *SessionCreate { - sc.mutation.SetHostPlatform(sp) - return sc -} - -// SetNillableHostPlatform sets the "host_platform" field if the given value is not nil. -func (sc *SessionCreate) SetNillableHostPlatform(sp *session.HostPlatform) *SessionCreate { - if sp != nil { - sc.SetHostPlatform(*sp) - } - return sc -} - -// SetLastSeenAt sets the "last_seen_at" field. -func (sc *SessionCreate) SetLastSeenAt(t time.Time) *SessionCreate { - sc.mutation.SetLastSeenAt(t) - return sc -} - -// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. -func (sc *SessionCreate) SetNillableLastSeenAt(t *time.Time) *SessionCreate { - if t != nil { - sc.SetLastSeenAt(*t) - } - return sc -} - -// AddTagIDs adds the "tags" edge to the Tag entity by IDs. -func (sc *SessionCreate) AddTagIDs(ids ...int) *SessionCreate { - sc.mutation.AddTagIDs(ids...) - return sc -} - -// AddTags adds the "tags" edges to the Tag entity. -func (sc *SessionCreate) AddTags(t ...*Tag) *SessionCreate { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return sc.AddTagIDs(ids...) -} - -// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. -func (sc *SessionCreate) AddTaskIDs(ids ...int) *SessionCreate { - sc.mutation.AddTaskIDs(ids...) - return sc -} - -// AddTasks adds the "tasks" edges to the Task entity. -func (sc *SessionCreate) AddTasks(t ...*Task) *SessionCreate { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return sc.AddTaskIDs(ids...) -} - -// Mutation returns the SessionMutation object of the builder. -func (sc *SessionCreate) Mutation() *SessionMutation { - return sc.mutation -} - -// Save creates the Session in the database. -func (sc *SessionCreate) Save(ctx context.Context) (*Session, error) { - sc.defaults() - return withHooks[*Session, SessionMutation](ctx, sc.sqlSave, sc.mutation, sc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (sc *SessionCreate) SaveX(ctx context.Context) *Session { - v, err := sc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (sc *SessionCreate) Exec(ctx context.Context) error { - _, err := sc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (sc *SessionCreate) ExecX(ctx context.Context) { - if err := sc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (sc *SessionCreate) defaults() { - if _, ok := sc.mutation.Name(); !ok { - v := session.DefaultName() - sc.mutation.SetName(v) - } - if _, ok := sc.mutation.Identifier(); !ok { - v := session.DefaultIdentifier() - sc.mutation.SetIdentifier(v) - } - if _, ok := sc.mutation.HostPlatform(); !ok { - v := session.DefaultHostPlatform - sc.mutation.SetHostPlatform(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (sc *SessionCreate) check() error { - if _, ok := sc.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Session.name"`)} - } - if v, ok := sc.mutation.Name(); ok { - if err := session.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Session.name": %w`, err)} - } - } - if v, ok := sc.mutation.Principal(); ok { - if err := session.PrincipalValidator(v); err != nil { - return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Session.principal": %w`, err)} - } - } - if v, ok := sc.mutation.Hostname(); ok { - if err := session.HostnameValidator(v); err != nil { - return &ValidationError{Name: "hostname", err: fmt.Errorf(`ent: validator failed for field "Session.hostname": %w`, err)} - } - } - if _, ok := sc.mutation.Identifier(); !ok { - return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "Session.identifier"`)} - } - if v, ok := sc.mutation.Identifier(); ok { - if err := session.IdentifierValidator(v); err != nil { - return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Session.identifier": %w`, err)} - } - } - if v, ok := sc.mutation.AgentIdentifier(); ok { - if err := session.AgentIdentifierValidator(v); err != nil { - return &ValidationError{Name: "agent_identifier", err: fmt.Errorf(`ent: validator failed for field "Session.agent_identifier": %w`, err)} - } - } - if v, ok := sc.mutation.HostIdentifier(); ok { - if err := session.HostIdentifierValidator(v); err != nil { - return &ValidationError{Name: "host_identifier", err: fmt.Errorf(`ent: validator failed for field "Session.host_identifier": %w`, err)} - } - } - if _, ok := sc.mutation.HostPlatform(); !ok { - return &ValidationError{Name: "host_platform", err: errors.New(`ent: missing required field "Session.host_platform"`)} - } - if v, ok := sc.mutation.HostPlatform(); ok { - if err := session.HostPlatformValidator(v); err != nil { - return &ValidationError{Name: "host_platform", err: fmt.Errorf(`ent: validator failed for field "Session.host_platform": %w`, err)} - } - } - return nil -} - -func (sc *SessionCreate) sqlSave(ctx context.Context) (*Session, error) { - if err := sc.check(); err != nil { - return nil, err - } - _node, _spec := sc.createSpec() - if err := sqlgraph.CreateNode(ctx, sc.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) - sc.mutation.id = &_node.ID - sc.mutation.done = true - return _node, nil -} - -func (sc *SessionCreate) createSpec() (*Session, *sqlgraph.CreateSpec) { - var ( - _node = &Session{config: sc.config} - _spec = sqlgraph.NewCreateSpec(session.Table, sqlgraph.NewFieldSpec(session.FieldID, field.TypeInt)) - ) - if value, ok := sc.mutation.Name(); ok { - _spec.SetField(session.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := sc.mutation.Principal(); ok { - _spec.SetField(session.FieldPrincipal, field.TypeString, value) - _node.Principal = value - } - if value, ok := sc.mutation.Hostname(); ok { - _spec.SetField(session.FieldHostname, field.TypeString, value) - _node.Hostname = value - } - if value, ok := sc.mutation.Identifier(); ok { - _spec.SetField(session.FieldIdentifier, field.TypeString, value) - _node.Identifier = value - } - if value, ok := sc.mutation.AgentIdentifier(); ok { - _spec.SetField(session.FieldAgentIdentifier, field.TypeString, value) - _node.AgentIdentifier = value - } - if value, ok := sc.mutation.HostIdentifier(); ok { - _spec.SetField(session.FieldHostIdentifier, field.TypeString, value) - _node.HostIdentifier = value - } - if value, ok := sc.mutation.HostPrimaryIP(); ok { - _spec.SetField(session.FieldHostPrimaryIP, field.TypeString, value) - _node.HostPrimaryIP = value - } - if value, ok := sc.mutation.HostPlatform(); ok { - _spec.SetField(session.FieldHostPlatform, field.TypeEnum, value) - _node.HostPlatform = value - } - if value, ok := sc.mutation.LastSeenAt(); ok { - _spec.SetField(session.FieldLastSeenAt, field.TypeTime, value) - _node.LastSeenAt = value - } - if nodes := sc.mutation.TagsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: session.TagsTable, - Columns: session.TagsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.mutation.TasksIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: session.TasksTable, - Columns: []string{session.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SessionCreateBulk is the builder for creating many Session entities in bulk. -type SessionCreateBulk struct { - config - builders []*SessionCreate -} - -// Save creates the Session entities in the database. -func (scb *SessionCreateBulk) Save(ctx context.Context) ([]*Session, error) { - specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) - nodes := make([]*Session, len(scb.builders)) - mutators := make([]Mutator, len(scb.builders)) - for i := range scb.builders { - func(i int, root context.Context) { - builder := scb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SessionMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, scb.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, scb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (scb *SessionCreateBulk) SaveX(ctx context.Context) []*Session { - v, err := scb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (scb *SessionCreateBulk) Exec(ctx context.Context) error { - _, err := scb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (scb *SessionCreateBulk) ExecX(ctx context.Context) { - if err := scb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/tavern/ent/session_delete.go b/tavern/ent/session_delete.go deleted file mode 100644 index 930cd0768..000000000 --- a/tavern/ent/session_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" - "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" -) - -// SessionDelete is the builder for deleting a Session entity. -type SessionDelete struct { - config - hooks []Hook - mutation *SessionMutation -} - -// Where appends a list predicates to the SessionDelete builder. -func (sd *SessionDelete) Where(ps ...predicate.Session) *SessionDelete { - sd.mutation.Where(ps...) - return sd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (sd *SessionDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, SessionMutation](ctx, sd.sqlExec, sd.mutation, sd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (sd *SessionDelete) ExecX(ctx context.Context) int { - n, err := sd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (sd *SessionDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(session.Table, sqlgraph.NewFieldSpec(session.FieldID, field.TypeInt)) - if ps := sd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - sd.mutation.done = true - return affected, err -} - -// SessionDeleteOne is the builder for deleting a single Session entity. -type SessionDeleteOne struct { - sd *SessionDelete -} - -// Where appends a list predicates to the SessionDelete builder. -func (sdo *SessionDeleteOne) Where(ps ...predicate.Session) *SessionDeleteOne { - sdo.sd.mutation.Where(ps...) - return sdo -} - -// Exec executes the deletion query. -func (sdo *SessionDeleteOne) Exec(ctx context.Context) error { - n, err := sdo.sd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{session.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (sdo *SessionDeleteOne) ExecX(ctx context.Context) { - if err := sdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/tavern/ent/session_query.go b/tavern/ent/session_query.go deleted file mode 100644 index 2efd68049..000000000 --- a/tavern/ent/session_query.go +++ /dev/null @@ -1,768 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" - "github.com/kcarretto/realm/tavern/ent/tag" - "github.com/kcarretto/realm/tavern/ent/task" -) - -// SessionQuery is the builder for querying Session entities. -type SessionQuery struct { - config - ctx *QueryContext - order []OrderFunc - inters []Interceptor - predicates []predicate.Session - withTags *TagQuery - withTasks *TaskQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Session) error - withNamedTags map[string]*TagQuery - withNamedTasks map[string]*TaskQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the SessionQuery builder. -func (sq *SessionQuery) Where(ps ...predicate.Session) *SessionQuery { - sq.predicates = append(sq.predicates, ps...) - return sq -} - -// Limit the number of records to be returned by this query. -func (sq *SessionQuery) Limit(limit int) *SessionQuery { - sq.ctx.Limit = &limit - return sq -} - -// Offset to start from. -func (sq *SessionQuery) Offset(offset int) *SessionQuery { - sq.ctx.Offset = &offset - return sq -} - -// 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 (sq *SessionQuery) Unique(unique bool) *SessionQuery { - sq.ctx.Unique = &unique - return sq -} - -// Order specifies how the records should be ordered. -func (sq *SessionQuery) Order(o ...OrderFunc) *SessionQuery { - sq.order = append(sq.order, o...) - return sq -} - -// QueryTags chains the current query on the "tags" edge. -func (sq *SessionQuery) QueryTags() *TagQuery { - query := (&TagClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(session.Table, session.FieldID, selector), - sqlgraph.To(tag.Table, tag.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, session.TagsTable, session.TagsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryTasks chains the current query on the "tasks" edge. -func (sq *SessionQuery) QueryTasks() *TaskQuery { - query := (&TaskClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(session.Table, session.FieldID, selector), - sqlgraph.To(task.Table, task.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, session.TasksTable, session.TasksColumn), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Session entity from the query. -// Returns a *NotFoundError when no Session was found. -func (sq *SessionQuery) First(ctx context.Context) (*Session, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{session.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (sq *SessionQuery) FirstX(ctx context.Context) *Session { - node, err := sq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Session ID from the query. -// Returns a *NotFoundError when no Session ID was found. -func (sq *SessionQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{session.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (sq *SessionQuery) FirstIDX(ctx context.Context) int { - id, err := sq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Session entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Session entity is found. -// Returns a *NotFoundError when no Session entities are found. -func (sq *SessionQuery) Only(ctx context.Context) (*Session, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{session.Label} - default: - return nil, &NotSingularError{session.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (sq *SessionQuery) OnlyX(ctx context.Context) *Session { - node, err := sq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Session ID in the query. -// Returns a *NotSingularError when more than one Session ID is found. -// Returns a *NotFoundError when no entities are found. -func (sq *SessionQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{session.Label} - default: - err = &NotSingularError{session.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *SessionQuery) OnlyIDX(ctx context.Context) int { - id, err := sq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Sessions. -func (sq *SessionQuery) All(ctx context.Context) ([]*Session, error) { - ctx = setContextOp(ctx, sq.ctx, "All") - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Session, *SessionQuery]() - return withInterceptors[[]*Session](ctx, sq, qr, sq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (sq *SessionQuery) AllX(ctx context.Context) []*Session { - nodes, err := sq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Session IDs. -func (sq *SessionQuery) IDs(ctx context.Context) (ids []int, err error) { - if sq.ctx.Unique == nil && sq.path != nil { - sq.Unique(true) - } - ctx = setContextOp(ctx, sq.ctx, "IDs") - if err = sq.Select(session.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (sq *SessionQuery) IDsX(ctx context.Context) []int { - ids, err := sq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (sq *SessionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") - if err := sq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, sq, querierCount[*SessionQuery](), sq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (sq *SessionQuery) CountX(ctx context.Context) int { - count, err := sq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (sq *SessionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") - switch _, err := sq.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 (sq *SessionQuery) ExistX(ctx context.Context) bool { - exist, err := sq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the SessionQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (sq *SessionQuery) Clone() *SessionQuery { - if sq == nil { - return nil - } - return &SessionQuery{ - config: sq.config, - ctx: sq.ctx.Clone(), - order: append([]OrderFunc{}, sq.order...), - inters: append([]Interceptor{}, sq.inters...), - predicates: append([]predicate.Session{}, sq.predicates...), - withTags: sq.withTags.Clone(), - withTasks: sq.withTasks.Clone(), - // clone intermediate query. - sql: sq.sql.Clone(), - path: sq.path, - } -} - -// WithTags tells the query-builder to eager-load the nodes that are connected to -// the "tags" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SessionQuery) WithTags(opts ...func(*TagQuery)) *SessionQuery { - query := (&TagClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withTags = query - return sq -} - -// WithTasks tells the query-builder to eager-load the nodes that are connected to -// the "tasks" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SessionQuery) WithTasks(opts ...func(*TaskQuery)) *SessionQuery { - query := (&TaskClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withTasks = query - return sq -} - -// 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 { -// Name string `json:"name,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Session.Query(). -// GroupBy(session.FieldName). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (sq *SessionQuery) GroupBy(field string, fields ...string) *SessionGroupBy { - sq.ctx.Fields = append([]string{field}, fields...) - grbuild := &SessionGroupBy{build: sq} - grbuild.flds = &sq.ctx.Fields - grbuild.label = session.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 { -// Name string `json:"name,omitempty"` -// } -// -// client.Session.Query(). -// Select(session.FieldName). -// Scan(ctx, &v) -func (sq *SessionQuery) Select(fields ...string) *SessionSelect { - sq.ctx.Fields = append(sq.ctx.Fields, fields...) - sbuild := &SessionSelect{SessionQuery: sq} - sbuild.label = session.Label - sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a SessionSelect configured with the given aggregations. -func (sq *SessionQuery) Aggregate(fns ...AggregateFunc) *SessionSelect { - return sq.Select().Aggregate(fns...) -} - -func (sq *SessionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range sq.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, sq); err != nil { - return err - } - } - } - for _, f := range sq.ctx.Fields { - if !session.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if sq.path != nil { - prev, err := sq.path(ctx) - if err != nil { - return err - } - sq.sql = prev - } - return nil -} - -func (sq *SessionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Session, error) { - var ( - nodes = []*Session{} - _spec = sq.querySpec() - loadedTypes = [2]bool{ - sq.withTags != nil, - sq.withTasks != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Session).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Session{config: sq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := sq.withTags; query != nil { - if err := sq.loadTags(ctx, query, nodes, - func(n *Session) { n.Edges.Tags = []*Tag{} }, - func(n *Session, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { - return nil, err - } - } - if query := sq.withTasks; query != nil { - if err := sq.loadTasks(ctx, query, nodes, - func(n *Session) { n.Edges.Tasks = []*Task{} }, - func(n *Session, e *Task) { n.Edges.Tasks = append(n.Edges.Tasks, e) }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedTags { - if err := sq.loadTags(ctx, query, nodes, - func(n *Session) { n.appendNamedTags(name) }, - func(n *Session, e *Tag) { n.appendNamedTags(name, e) }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedTasks { - if err := sq.loadTasks(ctx, query, nodes, - func(n *Session) { n.appendNamedTasks(name) }, - func(n *Session, e *Task) { n.appendNamedTasks(name, e) }); err != nil { - return nil, err - } - } - for i := range sq.loadTotal { - if err := sq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (sq *SessionQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Session, init func(*Session), assign func(*Session, *Tag)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*Session) - nids := make(map[int]map[*Session]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(session.TagsTable) - s.Join(joinT).On(s.C(tag.FieldID), joinT.C(session.TagsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(session.TagsPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(session.TagsPrimaryKey[0])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := int(values[0].(*sql.NullInt64).Int64) - inValue := int(values[1].(*sql.NullInt64).Int64) - if nids[inValue] == nil { - nids[inValue] = map[*Session]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Tag](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "tags" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (sq *SessionQuery) loadTasks(ctx context.Context, query *TaskQuery, nodes []*Session, init func(*Session), assign func(*Session, *Task)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Session) - 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.Task(func(s *sql.Selector) { - s.Where(sql.InValues(session.TasksColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.task_session - if fk == nil { - return fmt.Errorf(`foreign-key "task_session" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return fmt.Errorf(`unexpected foreign-key "task_session" returned %v for node %v`, *fk, n.ID) - } - assign(node, n) - } - return nil -} - -func (sq *SessionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := sq.querySpec() - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers - } - _spec.Node.Columns = sq.ctx.Fields - if len(sq.ctx.Fields) > 0 { - _spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, sq.driver, _spec) -} - -func (sq *SessionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(session.Table, session.Columns, sqlgraph.NewFieldSpec(session.FieldID, field.TypeInt)) - _spec.From = sq.sql - if unique := sq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if sq.path != nil { - _spec.Unique = true - } - if fields := sq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, session.FieldID) - for i := range fields { - if fields[i] != session.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := sq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := sq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := sq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := sq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (sq *SessionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(sq.driver.Dialect()) - t1 := builder.Table(session.Table) - columns := sq.ctx.Fields - if len(columns) == 0 { - columns = session.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if sq.sql != nil { - selector = sq.sql - selector.Select(selector.Columns(columns...)...) - } - if sq.ctx.Unique != nil && *sq.ctx.Unique { - selector.Distinct() - } - for _, p := range sq.predicates { - p(selector) - } - for _, p := range sq.order { - p(selector) - } - if offset := sq.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 := sq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedTags tells the query-builder to eager-load the nodes that are connected to the "tags" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SessionQuery) WithNamedTags(name string, opts ...func(*TagQuery)) *SessionQuery { - query := (&TagClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedTags == nil { - sq.withNamedTags = make(map[string]*TagQuery) - } - sq.withNamedTags[name] = query - return sq -} - -// WithNamedTasks tells the query-builder to eager-load the nodes that are connected to the "tasks" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SessionQuery) WithNamedTasks(name string, opts ...func(*TaskQuery)) *SessionQuery { - query := (&TaskClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedTasks == nil { - sq.withNamedTasks = make(map[string]*TaskQuery) - } - sq.withNamedTasks[name] = query - return sq -} - -// SessionGroupBy is the group-by builder for Session entities. -type SessionGroupBy struct { - selector - build *SessionQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (sgb *SessionGroupBy) Aggregate(fns ...AggregateFunc) *SessionGroupBy { - sgb.fns = append(sgb.fns, fns...) - return sgb -} - -// Scan applies the selector query and scans the result into the given value. -func (sgb *SessionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") - if err := sgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SessionQuery, *SessionGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v) -} - -func (sgb *SessionGroupBy) sqlScan(ctx context.Context, root *SessionQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(sgb.fns)) - for _, fn := range sgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) - for _, f := range *sgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*sgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// SessionSelect is the builder for selecting fields of Session entities. -type SessionSelect struct { - *SessionQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (ss *SessionSelect) Aggregate(fns ...AggregateFunc) *SessionSelect { - ss.fns = append(ss.fns, fns...) - return ss -} - -// Scan applies the selector query and scans the result into the given value. -func (ss *SessionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") - if err := ss.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SessionQuery, *SessionSelect](ctx, ss.SessionQuery, ss, ss.inters, v) -} - -func (ss *SessionSelect) sqlScan(ctx context.Context, root *SessionQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ss.fns)) - for _, fn := range ss.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*ss.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 := ss.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/tavern/ent/session_update.go b/tavern/ent/session_update.go deleted file mode 100644 index 2bbb825f9..000000000 --- a/tavern/ent/session_update.go +++ /dev/null @@ -1,1038 +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" - "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" - "github.com/kcarretto/realm/tavern/ent/tag" - "github.com/kcarretto/realm/tavern/ent/task" -) - -// SessionUpdate is the builder for updating Session entities. -type SessionUpdate struct { - config - hooks []Hook - mutation *SessionMutation -} - -// Where appends a list predicates to the SessionUpdate builder. -func (su *SessionUpdate) Where(ps ...predicate.Session) *SessionUpdate { - su.mutation.Where(ps...) - return su -} - -// SetName sets the "name" field. -func (su *SessionUpdate) SetName(s string) *SessionUpdate { - su.mutation.SetName(s) - return su -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (su *SessionUpdate) SetNillableName(s *string) *SessionUpdate { - if s != nil { - su.SetName(*s) - } - return su -} - -// SetPrincipal sets the "principal" field. -func (su *SessionUpdate) SetPrincipal(s string) *SessionUpdate { - su.mutation.SetPrincipal(s) - return su -} - -// SetNillablePrincipal sets the "principal" field if the given value is not nil. -func (su *SessionUpdate) SetNillablePrincipal(s *string) *SessionUpdate { - if s != nil { - su.SetPrincipal(*s) - } - return su -} - -// ClearPrincipal clears the value of the "principal" field. -func (su *SessionUpdate) ClearPrincipal() *SessionUpdate { - su.mutation.ClearPrincipal() - return su -} - -// SetHostname sets the "hostname" field. -func (su *SessionUpdate) SetHostname(s string) *SessionUpdate { - su.mutation.SetHostname(s) - return su -} - -// SetNillableHostname sets the "hostname" field if the given value is not nil. -func (su *SessionUpdate) SetNillableHostname(s *string) *SessionUpdate { - if s != nil { - su.SetHostname(*s) - } - return su -} - -// ClearHostname clears the value of the "hostname" field. -func (su *SessionUpdate) ClearHostname() *SessionUpdate { - su.mutation.ClearHostname() - return su -} - -// SetIdentifier sets the "identifier" field. -func (su *SessionUpdate) SetIdentifier(s string) *SessionUpdate { - su.mutation.SetIdentifier(s) - return su -} - -// SetNillableIdentifier sets the "identifier" field if the given value is not nil. -func (su *SessionUpdate) SetNillableIdentifier(s *string) *SessionUpdate { - if s != nil { - su.SetIdentifier(*s) - } - return su -} - -// SetAgentIdentifier sets the "agent_identifier" field. -func (su *SessionUpdate) SetAgentIdentifier(s string) *SessionUpdate { - su.mutation.SetAgentIdentifier(s) - return su -} - -// SetNillableAgentIdentifier sets the "agent_identifier" field if the given value is not nil. -func (su *SessionUpdate) SetNillableAgentIdentifier(s *string) *SessionUpdate { - if s != nil { - su.SetAgentIdentifier(*s) - } - return su -} - -// ClearAgentIdentifier clears the value of the "agent_identifier" field. -func (su *SessionUpdate) ClearAgentIdentifier() *SessionUpdate { - su.mutation.ClearAgentIdentifier() - return su -} - -// SetHostIdentifier sets the "host_identifier" field. -func (su *SessionUpdate) SetHostIdentifier(s string) *SessionUpdate { - su.mutation.SetHostIdentifier(s) - return su -} - -// SetNillableHostIdentifier sets the "host_identifier" field if the given value is not nil. -func (su *SessionUpdate) SetNillableHostIdentifier(s *string) *SessionUpdate { - if s != nil { - su.SetHostIdentifier(*s) - } - return su -} - -// ClearHostIdentifier clears the value of the "host_identifier" field. -func (su *SessionUpdate) ClearHostIdentifier() *SessionUpdate { - su.mutation.ClearHostIdentifier() - return su -} - -// SetHostPrimaryIP sets the "host_primary_ip" field. -func (su *SessionUpdate) SetHostPrimaryIP(s string) *SessionUpdate { - su.mutation.SetHostPrimaryIP(s) - return su -} - -// SetNillableHostPrimaryIP sets the "host_primary_ip" field if the given value is not nil. -func (su *SessionUpdate) SetNillableHostPrimaryIP(s *string) *SessionUpdate { - if s != nil { - su.SetHostPrimaryIP(*s) - } - return su -} - -// ClearHostPrimaryIP clears the value of the "host_primary_ip" field. -func (su *SessionUpdate) ClearHostPrimaryIP() *SessionUpdate { - su.mutation.ClearHostPrimaryIP() - return su -} - -// SetHostPlatform sets the "host_platform" field. -func (su *SessionUpdate) SetHostPlatform(sp session.HostPlatform) *SessionUpdate { - su.mutation.SetHostPlatform(sp) - return su -} - -// SetNillableHostPlatform sets the "host_platform" field if the given value is not nil. -func (su *SessionUpdate) SetNillableHostPlatform(sp *session.HostPlatform) *SessionUpdate { - if sp != nil { - su.SetHostPlatform(*sp) - } - return su -} - -// SetLastSeenAt sets the "last_seen_at" field. -func (su *SessionUpdate) SetLastSeenAt(t time.Time) *SessionUpdate { - su.mutation.SetLastSeenAt(t) - return su -} - -// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. -func (su *SessionUpdate) SetNillableLastSeenAt(t *time.Time) *SessionUpdate { - if t != nil { - su.SetLastSeenAt(*t) - } - return su -} - -// ClearLastSeenAt clears the value of the "last_seen_at" field. -func (su *SessionUpdate) ClearLastSeenAt() *SessionUpdate { - su.mutation.ClearLastSeenAt() - return su -} - -// AddTagIDs adds the "tags" edge to the Tag entity by IDs. -func (su *SessionUpdate) AddTagIDs(ids ...int) *SessionUpdate { - su.mutation.AddTagIDs(ids...) - return su -} - -// AddTags adds the "tags" edges to the Tag entity. -func (su *SessionUpdate) AddTags(t ...*Tag) *SessionUpdate { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return su.AddTagIDs(ids...) -} - -// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. -func (su *SessionUpdate) AddTaskIDs(ids ...int) *SessionUpdate { - su.mutation.AddTaskIDs(ids...) - return su -} - -// AddTasks adds the "tasks" edges to the Task entity. -func (su *SessionUpdate) AddTasks(t ...*Task) *SessionUpdate { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return su.AddTaskIDs(ids...) -} - -// Mutation returns the SessionMutation object of the builder. -func (su *SessionUpdate) Mutation() *SessionMutation { - return su.mutation -} - -// ClearTags clears all "tags" edges to the Tag entity. -func (su *SessionUpdate) ClearTags() *SessionUpdate { - su.mutation.ClearTags() - return su -} - -// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. -func (su *SessionUpdate) RemoveTagIDs(ids ...int) *SessionUpdate { - su.mutation.RemoveTagIDs(ids...) - return su -} - -// RemoveTags removes "tags" edges to Tag entities. -func (su *SessionUpdate) RemoveTags(t ...*Tag) *SessionUpdate { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return su.RemoveTagIDs(ids...) -} - -// ClearTasks clears all "tasks" edges to the Task entity. -func (su *SessionUpdate) ClearTasks() *SessionUpdate { - su.mutation.ClearTasks() - return su -} - -// RemoveTaskIDs removes the "tasks" edge to Task entities by IDs. -func (su *SessionUpdate) RemoveTaskIDs(ids ...int) *SessionUpdate { - su.mutation.RemoveTaskIDs(ids...) - return su -} - -// RemoveTasks removes "tasks" edges to Task entities. -func (su *SessionUpdate) RemoveTasks(t ...*Task) *SessionUpdate { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return su.RemoveTaskIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (su *SessionUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, SessionMutation](ctx, su.sqlSave, su.mutation, su.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (su *SessionUpdate) SaveX(ctx context.Context) int { - affected, err := su.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (su *SessionUpdate) Exec(ctx context.Context) error { - _, err := su.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (su *SessionUpdate) ExecX(ctx context.Context) { - if err := su.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (su *SessionUpdate) check() error { - if v, ok := su.mutation.Name(); ok { - if err := session.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Session.name": %w`, err)} - } - } - if v, ok := su.mutation.Principal(); ok { - if err := session.PrincipalValidator(v); err != nil { - return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Session.principal": %w`, err)} - } - } - if v, ok := su.mutation.Hostname(); ok { - if err := session.HostnameValidator(v); err != nil { - return &ValidationError{Name: "hostname", err: fmt.Errorf(`ent: validator failed for field "Session.hostname": %w`, err)} - } - } - if v, ok := su.mutation.Identifier(); ok { - if err := session.IdentifierValidator(v); err != nil { - return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Session.identifier": %w`, err)} - } - } - if v, ok := su.mutation.AgentIdentifier(); ok { - if err := session.AgentIdentifierValidator(v); err != nil { - return &ValidationError{Name: "agent_identifier", err: fmt.Errorf(`ent: validator failed for field "Session.agent_identifier": %w`, err)} - } - } - if v, ok := su.mutation.HostIdentifier(); ok { - if err := session.HostIdentifierValidator(v); err != nil { - return &ValidationError{Name: "host_identifier", err: fmt.Errorf(`ent: validator failed for field "Session.host_identifier": %w`, err)} - } - } - if v, ok := su.mutation.HostPlatform(); ok { - if err := session.HostPlatformValidator(v); err != nil { - return &ValidationError{Name: "host_platform", err: fmt.Errorf(`ent: validator failed for field "Session.host_platform": %w`, err)} - } - } - return nil -} - -func (su *SessionUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := su.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(session.Table, session.Columns, sqlgraph.NewFieldSpec(session.FieldID, field.TypeInt)) - if ps := su.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := su.mutation.Name(); ok { - _spec.SetField(session.FieldName, field.TypeString, value) - } - if value, ok := su.mutation.Principal(); ok { - _spec.SetField(session.FieldPrincipal, field.TypeString, value) - } - if su.mutation.PrincipalCleared() { - _spec.ClearField(session.FieldPrincipal, field.TypeString) - } - if value, ok := su.mutation.Hostname(); ok { - _spec.SetField(session.FieldHostname, field.TypeString, value) - } - if su.mutation.HostnameCleared() { - _spec.ClearField(session.FieldHostname, field.TypeString) - } - if value, ok := su.mutation.Identifier(); ok { - _spec.SetField(session.FieldIdentifier, field.TypeString, value) - } - if value, ok := su.mutation.AgentIdentifier(); ok { - _spec.SetField(session.FieldAgentIdentifier, field.TypeString, value) - } - if su.mutation.AgentIdentifierCleared() { - _spec.ClearField(session.FieldAgentIdentifier, field.TypeString) - } - if value, ok := su.mutation.HostIdentifier(); ok { - _spec.SetField(session.FieldHostIdentifier, field.TypeString, value) - } - if su.mutation.HostIdentifierCleared() { - _spec.ClearField(session.FieldHostIdentifier, field.TypeString) - } - if value, ok := su.mutation.HostPrimaryIP(); ok { - _spec.SetField(session.FieldHostPrimaryIP, field.TypeString, value) - } - if su.mutation.HostPrimaryIPCleared() { - _spec.ClearField(session.FieldHostPrimaryIP, field.TypeString) - } - if value, ok := su.mutation.HostPlatform(); ok { - _spec.SetField(session.FieldHostPlatform, field.TypeEnum, value) - } - if value, ok := su.mutation.LastSeenAt(); ok { - _spec.SetField(session.FieldLastSeenAt, field.TypeTime, value) - } - if su.mutation.LastSeenAtCleared() { - _spec.ClearField(session.FieldLastSeenAt, field.TypeTime) - } - if su.mutation.TagsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: session.TagsTable, - Columns: session.TagsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedTagsIDs(); len(nodes) > 0 && !su.mutation.TagsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: session.TagsTable, - Columns: session.TagsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.TagsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: session.TagsTable, - Columns: session.TagsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if su.mutation.TasksCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: session.TasksTable, - Columns: []string{session.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedTasksIDs(); len(nodes) > 0 && !su.mutation.TasksCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: session.TasksTable, - Columns: []string{session.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.TasksIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: session.TasksTable, - Columns: []string{session.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - 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, su.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{session.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - su.mutation.done = true - return n, nil -} - -// SessionUpdateOne is the builder for updating a single Session entity. -type SessionUpdateOne struct { - config - fields []string - hooks []Hook - mutation *SessionMutation -} - -// SetName sets the "name" field. -func (suo *SessionUpdateOne) SetName(s string) *SessionUpdateOne { - suo.mutation.SetName(s) - return suo -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableName(s *string) *SessionUpdateOne { - if s != nil { - suo.SetName(*s) - } - return suo -} - -// SetPrincipal sets the "principal" field. -func (suo *SessionUpdateOne) SetPrincipal(s string) *SessionUpdateOne { - suo.mutation.SetPrincipal(s) - return suo -} - -// SetNillablePrincipal sets the "principal" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillablePrincipal(s *string) *SessionUpdateOne { - if s != nil { - suo.SetPrincipal(*s) - } - return suo -} - -// ClearPrincipal clears the value of the "principal" field. -func (suo *SessionUpdateOne) ClearPrincipal() *SessionUpdateOne { - suo.mutation.ClearPrincipal() - return suo -} - -// SetHostname sets the "hostname" field. -func (suo *SessionUpdateOne) SetHostname(s string) *SessionUpdateOne { - suo.mutation.SetHostname(s) - return suo -} - -// SetNillableHostname sets the "hostname" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableHostname(s *string) *SessionUpdateOne { - if s != nil { - suo.SetHostname(*s) - } - return suo -} - -// ClearHostname clears the value of the "hostname" field. -func (suo *SessionUpdateOne) ClearHostname() *SessionUpdateOne { - suo.mutation.ClearHostname() - return suo -} - -// SetIdentifier sets the "identifier" field. -func (suo *SessionUpdateOne) SetIdentifier(s string) *SessionUpdateOne { - suo.mutation.SetIdentifier(s) - return suo -} - -// SetNillableIdentifier sets the "identifier" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableIdentifier(s *string) *SessionUpdateOne { - if s != nil { - suo.SetIdentifier(*s) - } - return suo -} - -// SetAgentIdentifier sets the "agent_identifier" field. -func (suo *SessionUpdateOne) SetAgentIdentifier(s string) *SessionUpdateOne { - suo.mutation.SetAgentIdentifier(s) - return suo -} - -// SetNillableAgentIdentifier sets the "agent_identifier" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableAgentIdentifier(s *string) *SessionUpdateOne { - if s != nil { - suo.SetAgentIdentifier(*s) - } - return suo -} - -// ClearAgentIdentifier clears the value of the "agent_identifier" field. -func (suo *SessionUpdateOne) ClearAgentIdentifier() *SessionUpdateOne { - suo.mutation.ClearAgentIdentifier() - return suo -} - -// SetHostIdentifier sets the "host_identifier" field. -func (suo *SessionUpdateOne) SetHostIdentifier(s string) *SessionUpdateOne { - suo.mutation.SetHostIdentifier(s) - return suo -} - -// SetNillableHostIdentifier sets the "host_identifier" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableHostIdentifier(s *string) *SessionUpdateOne { - if s != nil { - suo.SetHostIdentifier(*s) - } - return suo -} - -// ClearHostIdentifier clears the value of the "host_identifier" field. -func (suo *SessionUpdateOne) ClearHostIdentifier() *SessionUpdateOne { - suo.mutation.ClearHostIdentifier() - return suo -} - -// SetHostPrimaryIP sets the "host_primary_ip" field. -func (suo *SessionUpdateOne) SetHostPrimaryIP(s string) *SessionUpdateOne { - suo.mutation.SetHostPrimaryIP(s) - return suo -} - -// SetNillableHostPrimaryIP sets the "host_primary_ip" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableHostPrimaryIP(s *string) *SessionUpdateOne { - if s != nil { - suo.SetHostPrimaryIP(*s) - } - return suo -} - -// ClearHostPrimaryIP clears the value of the "host_primary_ip" field. -func (suo *SessionUpdateOne) ClearHostPrimaryIP() *SessionUpdateOne { - suo.mutation.ClearHostPrimaryIP() - return suo -} - -// SetHostPlatform sets the "host_platform" field. -func (suo *SessionUpdateOne) SetHostPlatform(sp session.HostPlatform) *SessionUpdateOne { - suo.mutation.SetHostPlatform(sp) - return suo -} - -// SetNillableHostPlatform sets the "host_platform" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableHostPlatform(sp *session.HostPlatform) *SessionUpdateOne { - if sp != nil { - suo.SetHostPlatform(*sp) - } - return suo -} - -// SetLastSeenAt sets the "last_seen_at" field. -func (suo *SessionUpdateOne) SetLastSeenAt(t time.Time) *SessionUpdateOne { - suo.mutation.SetLastSeenAt(t) - return suo -} - -// SetNillableLastSeenAt sets the "last_seen_at" field if the given value is not nil. -func (suo *SessionUpdateOne) SetNillableLastSeenAt(t *time.Time) *SessionUpdateOne { - if t != nil { - suo.SetLastSeenAt(*t) - } - return suo -} - -// ClearLastSeenAt clears the value of the "last_seen_at" field. -func (suo *SessionUpdateOne) ClearLastSeenAt() *SessionUpdateOne { - suo.mutation.ClearLastSeenAt() - return suo -} - -// AddTagIDs adds the "tags" edge to the Tag entity by IDs. -func (suo *SessionUpdateOne) AddTagIDs(ids ...int) *SessionUpdateOne { - suo.mutation.AddTagIDs(ids...) - return suo -} - -// AddTags adds the "tags" edges to the Tag entity. -func (suo *SessionUpdateOne) AddTags(t ...*Tag) *SessionUpdateOne { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return suo.AddTagIDs(ids...) -} - -// AddTaskIDs adds the "tasks" edge to the Task entity by IDs. -func (suo *SessionUpdateOne) AddTaskIDs(ids ...int) *SessionUpdateOne { - suo.mutation.AddTaskIDs(ids...) - return suo -} - -// AddTasks adds the "tasks" edges to the Task entity. -func (suo *SessionUpdateOne) AddTasks(t ...*Task) *SessionUpdateOne { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return suo.AddTaskIDs(ids...) -} - -// Mutation returns the SessionMutation object of the builder. -func (suo *SessionUpdateOne) Mutation() *SessionMutation { - return suo.mutation -} - -// ClearTags clears all "tags" edges to the Tag entity. -func (suo *SessionUpdateOne) ClearTags() *SessionUpdateOne { - suo.mutation.ClearTags() - return suo -} - -// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. -func (suo *SessionUpdateOne) RemoveTagIDs(ids ...int) *SessionUpdateOne { - suo.mutation.RemoveTagIDs(ids...) - return suo -} - -// RemoveTags removes "tags" edges to Tag entities. -func (suo *SessionUpdateOne) RemoveTags(t ...*Tag) *SessionUpdateOne { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return suo.RemoveTagIDs(ids...) -} - -// ClearTasks clears all "tasks" edges to the Task entity. -func (suo *SessionUpdateOne) ClearTasks() *SessionUpdateOne { - suo.mutation.ClearTasks() - return suo -} - -// RemoveTaskIDs removes the "tasks" edge to Task entities by IDs. -func (suo *SessionUpdateOne) RemoveTaskIDs(ids ...int) *SessionUpdateOne { - suo.mutation.RemoveTaskIDs(ids...) - return suo -} - -// RemoveTasks removes "tasks" edges to Task entities. -func (suo *SessionUpdateOne) RemoveTasks(t ...*Task) *SessionUpdateOne { - ids := make([]int, len(t)) - for i := range t { - ids[i] = t[i].ID - } - return suo.RemoveTaskIDs(ids...) -} - -// Where appends a list predicates to the SessionUpdate builder. -func (suo *SessionUpdateOne) Where(ps ...predicate.Session) *SessionUpdateOne { - suo.mutation.Where(ps...) - return suo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (suo *SessionUpdateOne) Select(field string, fields ...string) *SessionUpdateOne { - suo.fields = append([]string{field}, fields...) - return suo -} - -// Save executes the query and returns the updated Session entity. -func (suo *SessionUpdateOne) Save(ctx context.Context) (*Session, error) { - return withHooks[*Session, SessionMutation](ctx, suo.sqlSave, suo.mutation, suo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (suo *SessionUpdateOne) SaveX(ctx context.Context) *Session { - node, err := suo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (suo *SessionUpdateOne) Exec(ctx context.Context) error { - _, err := suo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (suo *SessionUpdateOne) ExecX(ctx context.Context) { - if err := suo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (suo *SessionUpdateOne) check() error { - if v, ok := suo.mutation.Name(); ok { - if err := session.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Session.name": %w`, err)} - } - } - if v, ok := suo.mutation.Principal(); ok { - if err := session.PrincipalValidator(v); err != nil { - return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Session.principal": %w`, err)} - } - } - if v, ok := suo.mutation.Hostname(); ok { - if err := session.HostnameValidator(v); err != nil { - return &ValidationError{Name: "hostname", err: fmt.Errorf(`ent: validator failed for field "Session.hostname": %w`, err)} - } - } - if v, ok := suo.mutation.Identifier(); ok { - if err := session.IdentifierValidator(v); err != nil { - return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Session.identifier": %w`, err)} - } - } - if v, ok := suo.mutation.AgentIdentifier(); ok { - if err := session.AgentIdentifierValidator(v); err != nil { - return &ValidationError{Name: "agent_identifier", err: fmt.Errorf(`ent: validator failed for field "Session.agent_identifier": %w`, err)} - } - } - if v, ok := suo.mutation.HostIdentifier(); ok { - if err := session.HostIdentifierValidator(v); err != nil { - return &ValidationError{Name: "host_identifier", err: fmt.Errorf(`ent: validator failed for field "Session.host_identifier": %w`, err)} - } - } - if v, ok := suo.mutation.HostPlatform(); ok { - if err := session.HostPlatformValidator(v); err != nil { - return &ValidationError{Name: "host_platform", err: fmt.Errorf(`ent: validator failed for field "Session.host_platform": %w`, err)} - } - } - return nil -} - -func (suo *SessionUpdateOne) sqlSave(ctx context.Context) (_node *Session, err error) { - if err := suo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(session.Table, session.Columns, sqlgraph.NewFieldSpec(session.FieldID, field.TypeInt)) - id, ok := suo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Session.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := suo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, session.FieldID) - for _, f := range fields { - if !session.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != session.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := suo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := suo.mutation.Name(); ok { - _spec.SetField(session.FieldName, field.TypeString, value) - } - if value, ok := suo.mutation.Principal(); ok { - _spec.SetField(session.FieldPrincipal, field.TypeString, value) - } - if suo.mutation.PrincipalCleared() { - _spec.ClearField(session.FieldPrincipal, field.TypeString) - } - if value, ok := suo.mutation.Hostname(); ok { - _spec.SetField(session.FieldHostname, field.TypeString, value) - } - if suo.mutation.HostnameCleared() { - _spec.ClearField(session.FieldHostname, field.TypeString) - } - if value, ok := suo.mutation.Identifier(); ok { - _spec.SetField(session.FieldIdentifier, field.TypeString, value) - } - if value, ok := suo.mutation.AgentIdentifier(); ok { - _spec.SetField(session.FieldAgentIdentifier, field.TypeString, value) - } - if suo.mutation.AgentIdentifierCleared() { - _spec.ClearField(session.FieldAgentIdentifier, field.TypeString) - } - if value, ok := suo.mutation.HostIdentifier(); ok { - _spec.SetField(session.FieldHostIdentifier, field.TypeString, value) - } - if suo.mutation.HostIdentifierCleared() { - _spec.ClearField(session.FieldHostIdentifier, field.TypeString) - } - if value, ok := suo.mutation.HostPrimaryIP(); ok { - _spec.SetField(session.FieldHostPrimaryIP, field.TypeString, value) - } - if suo.mutation.HostPrimaryIPCleared() { - _spec.ClearField(session.FieldHostPrimaryIP, field.TypeString) - } - if value, ok := suo.mutation.HostPlatform(); ok { - _spec.SetField(session.FieldHostPlatform, field.TypeEnum, value) - } - if value, ok := suo.mutation.LastSeenAt(); ok { - _spec.SetField(session.FieldLastSeenAt, field.TypeTime, value) - } - if suo.mutation.LastSeenAtCleared() { - _spec.ClearField(session.FieldLastSeenAt, field.TypeTime) - } - if suo.mutation.TagsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: session.TagsTable, - Columns: session.TagsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedTagsIDs(); len(nodes) > 0 && !suo.mutation.TagsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: session.TagsTable, - Columns: session.TagsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.TagsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: session.TagsTable, - Columns: session.TagsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if suo.mutation.TasksCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: session.TasksTable, - Columns: []string{session.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedTasksIDs(); len(nodes) > 0 && !suo.mutation.TasksCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: session.TasksTable, - Columns: []string{session.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.TasksIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: session.TasksTable, - Columns: []string{session.TasksColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &Session{config: suo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{session.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - suo.mutation.done = true - return _node, nil -} diff --git a/tavern/ent/tag.go b/tavern/ent/tag.go index a537b663a..635c67a98 100644 --- a/tavern/ent/tag.go +++ b/tavern/ent/tag.go @@ -26,24 +26,24 @@ type Tag struct { // TagEdges holds the relations/edges for other nodes in the graph. type TagEdges struct { - // Sessions holds the value of the sessions edge. - Sessions []*Session `json:"sessions,omitempty"` + // Beacons holds the value of the beacons edge. + Beacons []*Beacon `json:"beacons,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool // totalCount holds the count of the edges above. totalCount [1]map[string]int - namedSessions map[string][]*Session + namedBeacons map[string][]*Beacon } -// SessionsOrErr returns the Sessions value or an error if the edge +// BeaconsOrErr returns the Beacons value or an error if the edge // was not loaded in eager-loading. -func (e TagEdges) SessionsOrErr() ([]*Session, error) { +func (e TagEdges) BeaconsOrErr() ([]*Beacon, error) { if e.loadedTypes[0] { - return e.Sessions, nil + return e.Beacons, nil } - return nil, &NotLoadedError{edge: "sessions"} + return nil, &NotLoadedError{edge: "beacons"} } // scanValues returns the types for scanning values from sql.Rows. @@ -93,9 +93,9 @@ func (t *Tag) assignValues(columns []string, values []any) error { return nil } -// QuerySessions queries the "sessions" edge of the Tag entity. -func (t *Tag) QuerySessions() *SessionQuery { - return NewTagClient(t.config).QuerySessions(t) +// QueryBeacons queries the "beacons" edge of the Tag entity. +func (t *Tag) QueryBeacons() *BeaconQuery { + return NewTagClient(t.config).QueryBeacons(t) } // Update returns a builder for updating this Tag. @@ -130,27 +130,27 @@ func (t *Tag) String() string { return builder.String() } -// NamedSessions returns the Sessions named value or an error if the edge was not +// NamedBeacons returns the Beacons named value or an error if the edge was not // loaded in eager-loading with this name. -func (t *Tag) NamedSessions(name string) ([]*Session, error) { - if t.Edges.namedSessions == nil { +func (t *Tag) NamedBeacons(name string) ([]*Beacon, error) { + if t.Edges.namedBeacons == nil { return nil, &NotLoadedError{edge: name} } - nodes, ok := t.Edges.namedSessions[name] + nodes, ok := t.Edges.namedBeacons[name] if !ok { return nil, &NotLoadedError{edge: name} } return nodes, nil } -func (t *Tag) appendNamedSessions(name string, edges ...*Session) { - if t.Edges.namedSessions == nil { - t.Edges.namedSessions = make(map[string][]*Session) +func (t *Tag) appendNamedBeacons(name string, edges ...*Beacon) { + if t.Edges.namedBeacons == nil { + t.Edges.namedBeacons = make(map[string][]*Beacon) } if len(edges) == 0 { - t.Edges.namedSessions[name] = []*Session{} + t.Edges.namedBeacons[name] = []*Beacon{} } else { - t.Edges.namedSessions[name] = append(t.Edges.namedSessions[name], edges...) + t.Edges.namedBeacons[name] = append(t.Edges.namedBeacons[name], edges...) } } diff --git a/tavern/ent/tag/tag.go b/tavern/ent/tag/tag.go index 6a8922fdf..649fac375 100644 --- a/tavern/ent/tag/tag.go +++ b/tavern/ent/tag/tag.go @@ -17,15 +17,15 @@ const ( FieldName = "name" // FieldKind holds the string denoting the kind field in the database. FieldKind = "kind" - // EdgeSessions holds the string denoting the sessions edge name in mutations. - EdgeSessions = "sessions" + // EdgeBeacons holds the string denoting the beacons edge name in mutations. + EdgeBeacons = "beacons" // Table holds the table name of the tag in the database. Table = "tags" - // SessionsTable is the table that holds the sessions relation/edge. The primary key declared below. - SessionsTable = "session_tags" - // SessionsInverseTable is the table name for the Session entity. - // It exists in this package in order to avoid circular dependency with the "session" package. - SessionsInverseTable = "sessions" + // BeaconsTable is the table that holds the beacons relation/edge. The primary key declared below. + BeaconsTable = "beacon_tags" + // BeaconsInverseTable is the table name for the Beacon entity. + // It exists in this package in order to avoid circular dependency with the "beacon" package. + BeaconsInverseTable = "beacons" ) // Columns holds all SQL columns for tag fields. @@ -36,9 +36,9 @@ var Columns = []string{ } var ( - // SessionsPrimaryKey and SessionsColumn2 are the table columns denoting the - // primary key for the sessions relation (M2M). - SessionsPrimaryKey = []string{"session_id", "tag_id"} + // BeaconsPrimaryKey and BeaconsColumn2 are the table columns denoting the + // primary key for the beacons relation (M2M). + BeaconsPrimaryKey = []string{"beacon_id", "tag_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/tavern/ent/tag/where.go b/tavern/ent/tag/where.go index 637468d66..883dcdc81 100644 --- a/tavern/ent/tag/where.go +++ b/tavern/ent/tag/where.go @@ -143,24 +143,24 @@ func KindNotIn(vs ...Kind) predicate.Tag { return predicate.Tag(sql.FieldNotIn(FieldKind, vs...)) } -// HasSessions applies the HasEdge predicate on the "sessions" edge. -func HasSessions() predicate.Tag { +// HasBeacons applies the HasEdge predicate on the "beacons" edge. +func HasBeacons() predicate.Tag { return predicate.Tag(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, SessionsTable, SessionsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, BeaconsTable, BeaconsPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) }) } -// HasSessionsWith applies the HasEdge predicate on the "sessions" edge with a given conditions (other predicates). -func HasSessionsWith(preds ...predicate.Session) predicate.Tag { +// HasBeaconsWith applies the HasEdge predicate on the "beacons" edge with a given conditions (other predicates). +func HasBeaconsWith(preds ...predicate.Beacon) predicate.Tag { return predicate.Tag(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(SessionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, SessionsTable, SessionsPrimaryKey...), + sqlgraph.To(BeaconsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, BeaconsTable, BeaconsPrimaryKey...), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { diff --git a/tavern/ent/tag_create.go b/tavern/ent/tag_create.go index 984a426c0..1c1f235ad 100644 --- a/tavern/ent/tag_create.go +++ b/tavern/ent/tag_create.go @@ -9,7 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/tag" ) @@ -32,19 +32,19 @@ func (tc *TagCreate) SetKind(t tag.Kind) *TagCreate { return tc } -// AddSessionIDs adds the "sessions" edge to the Session entity by IDs. -func (tc *TagCreate) AddSessionIDs(ids ...int) *TagCreate { - tc.mutation.AddSessionIDs(ids...) +// AddBeaconIDs adds the "beacons" edge to the Beacon entity by IDs. +func (tc *TagCreate) AddBeaconIDs(ids ...int) *TagCreate { + tc.mutation.AddBeaconIDs(ids...) return tc } -// AddSessions adds the "sessions" edges to the Session entity. -func (tc *TagCreate) AddSessions(s ...*Session) *TagCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddBeacons adds the "beacons" edges to the Beacon entity. +func (tc *TagCreate) AddBeacons(b ...*Beacon) *TagCreate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID } - return tc.AddSessionIDs(ids...) + return tc.AddBeaconIDs(ids...) } // Mutation returns the TagMutation object of the builder. @@ -131,17 +131,17 @@ func (tc *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) { _spec.SetField(tag.FieldKind, field.TypeEnum, value) _node.Kind = value } - if nodes := tc.mutation.SessionsIDs(); len(nodes) > 0 { + if nodes := tc.mutation.BeaconsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: tag.SessionsTable, - Columns: tag.SessionsPrimaryKey, + Table: tag.BeaconsTable, + Columns: tag.BeaconsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } diff --git a/tavern/ent/tag_query.go b/tavern/ent/tag_query.go index 54bd79be8..b628e2642 100644 --- a/tavern/ent/tag_query.go +++ b/tavern/ent/tag_query.go @@ -11,22 +11,22 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" "github.com/kcarretto/realm/tavern/ent/tag" ) // TagQuery is the builder for querying Tag entities. type TagQuery struct { config - ctx *QueryContext - order []OrderFunc - inters []Interceptor - predicates []predicate.Tag - withSessions *SessionQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Tag) error - withNamedSessions map[string]*SessionQuery + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Tag + withBeacons *BeaconQuery + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Tag) error + withNamedBeacons map[string]*BeaconQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -63,9 +63,9 @@ func (tq *TagQuery) Order(o ...OrderFunc) *TagQuery { return tq } -// QuerySessions chains the current query on the "sessions" edge. -func (tq *TagQuery) QuerySessions() *SessionQuery { - query := (&SessionClient{config: tq.config}).Query() +// QueryBeacons chains the current query on the "beacons" edge. +func (tq *TagQuery) QueryBeacons() *BeaconQuery { + query := (&BeaconClient{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 @@ -76,8 +76,8 @@ func (tq *TagQuery) QuerySessions() *SessionQuery { } step := sqlgraph.NewStep( sqlgraph.From(tag.Table, tag.FieldID, selector), - sqlgraph.To(session.Table, session.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, tag.SessionsTable, tag.SessionsPrimaryKey...), + sqlgraph.To(beacon.Table, beacon.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.BeaconsTable, tag.BeaconsPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) return fromU, nil @@ -272,26 +272,26 @@ func (tq *TagQuery) Clone() *TagQuery { return nil } return &TagQuery{ - config: tq.config, - ctx: tq.ctx.Clone(), - order: append([]OrderFunc{}, tq.order...), - inters: append([]Interceptor{}, tq.inters...), - predicates: append([]predicate.Tag{}, tq.predicates...), - withSessions: tq.withSessions.Clone(), + config: tq.config, + ctx: tq.ctx.Clone(), + order: append([]OrderFunc{}, tq.order...), + inters: append([]Interceptor{}, tq.inters...), + predicates: append([]predicate.Tag{}, tq.predicates...), + withBeacons: tq.withBeacons.Clone(), // clone intermediate query. sql: tq.sql.Clone(), path: tq.path, } } -// WithSessions tells the query-builder to eager-load the nodes that are connected to -// the "sessions" edge. The optional arguments are used to configure the query builder of the edge. -func (tq *TagQuery) WithSessions(opts ...func(*SessionQuery)) *TagQuery { - query := (&SessionClient{config: tq.config}).Query() +// WithBeacons tells the query-builder to eager-load the nodes that are connected to +// the "beacons" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TagQuery) WithBeacons(opts ...func(*BeaconQuery)) *TagQuery { + query := (&BeaconClient{config: tq.config}).Query() for _, opt := range opts { opt(query) } - tq.withSessions = query + tq.withBeacons = query return tq } @@ -374,7 +374,7 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err nodes = []*Tag{} _spec = tq.querySpec() loadedTypes = [1]bool{ - tq.withSessions != nil, + tq.withBeacons != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -398,17 +398,17 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err if len(nodes) == 0 { return nodes, nil } - if query := tq.withSessions; query != nil { - if err := tq.loadSessions(ctx, query, nodes, - func(n *Tag) { n.Edges.Sessions = []*Session{} }, - func(n *Tag, e *Session) { n.Edges.Sessions = append(n.Edges.Sessions, e) }); err != nil { + if query := tq.withBeacons; query != nil { + if err := tq.loadBeacons(ctx, query, nodes, + func(n *Tag) { n.Edges.Beacons = []*Beacon{} }, + func(n *Tag, e *Beacon) { n.Edges.Beacons = append(n.Edges.Beacons, e) }); err != nil { return nil, err } } - for name, query := range tq.withNamedSessions { - if err := tq.loadSessions(ctx, query, nodes, - func(n *Tag) { n.appendNamedSessions(name) }, - func(n *Tag, e *Session) { n.appendNamedSessions(name, e) }); err != nil { + for name, query := range tq.withNamedBeacons { + if err := tq.loadBeacons(ctx, query, nodes, + func(n *Tag) { n.appendNamedBeacons(name) }, + func(n *Tag, e *Beacon) { n.appendNamedBeacons(name, e) }); err != nil { return nil, err } } @@ -420,7 +420,7 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err return nodes, nil } -func (tq *TagQuery) loadSessions(ctx context.Context, query *SessionQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Session)) error { +func (tq *TagQuery) loadBeacons(ctx context.Context, query *BeaconQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Beacon)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int]*Tag) nids := make(map[int]map[*Tag]struct{}) @@ -432,11 +432,11 @@ func (tq *TagQuery) loadSessions(ctx context.Context, query *SessionQuery, nodes } } query.Where(func(s *sql.Selector) { - joinT := sql.Table(tag.SessionsTable) - s.Join(joinT).On(s.C(session.FieldID), joinT.C(tag.SessionsPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(tag.SessionsPrimaryKey[1]), edgeIDs...)) + joinT := sql.Table(tag.BeaconsTable) + s.Join(joinT).On(s.C(beacon.FieldID), joinT.C(tag.BeaconsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(tag.BeaconsPrimaryKey[1]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(tag.SessionsPrimaryKey[1])) + s.Select(joinT.C(tag.BeaconsPrimaryKey[1])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -466,14 +466,14 @@ func (tq *TagQuery) loadSessions(ctx context.Context, query *SessionQuery, nodes } }) }) - neighbors, err := withInterceptors[[]*Session](ctx, query, qr, query.inters) + neighbors, err := withInterceptors[[]*Beacon](ctx, query, qr, query.inters) if err != nil { return err } for _, n := range neighbors { nodes, ok := nids[n.ID] if !ok { - return fmt.Errorf(`unexpected "sessions" node returned %v`, n.ID) + return fmt.Errorf(`unexpected "beacons" node returned %v`, n.ID) } for kn := range nodes { assign(kn, n) @@ -566,17 +566,17 @@ func (tq *TagQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } -// WithNamedSessions tells the query-builder to eager-load the nodes that are connected to the "sessions" +// WithNamedBeacons tells the query-builder to eager-load the nodes that are connected to the "beacons" // edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (tq *TagQuery) WithNamedSessions(name string, opts ...func(*SessionQuery)) *TagQuery { - query := (&SessionClient{config: tq.config}).Query() +func (tq *TagQuery) WithNamedBeacons(name string, opts ...func(*BeaconQuery)) *TagQuery { + query := (&BeaconClient{config: tq.config}).Query() for _, opt := range opts { opt(query) } - if tq.withNamedSessions == nil { - tq.withNamedSessions = make(map[string]*SessionQuery) + if tq.withNamedBeacons == nil { + tq.withNamedBeacons = make(map[string]*BeaconQuery) } - tq.withNamedSessions[name] = query + tq.withNamedBeacons[name] = query return tq } diff --git a/tavern/ent/tag_update.go b/tavern/ent/tag_update.go index ba8f7fc20..152c2baea 100644 --- a/tavern/ent/tag_update.go +++ b/tavern/ent/tag_update.go @@ -10,8 +10,8 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" "github.com/kcarretto/realm/tavern/ent/tag" ) @@ -40,19 +40,19 @@ func (tu *TagUpdate) SetKind(t tag.Kind) *TagUpdate { return tu } -// AddSessionIDs adds the "sessions" edge to the Session entity by IDs. -func (tu *TagUpdate) AddSessionIDs(ids ...int) *TagUpdate { - tu.mutation.AddSessionIDs(ids...) +// AddBeaconIDs adds the "beacons" edge to the Beacon entity by IDs. +func (tu *TagUpdate) AddBeaconIDs(ids ...int) *TagUpdate { + tu.mutation.AddBeaconIDs(ids...) return tu } -// AddSessions adds the "sessions" edges to the Session entity. -func (tu *TagUpdate) AddSessions(s ...*Session) *TagUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddBeacons adds the "beacons" edges to the Beacon entity. +func (tu *TagUpdate) AddBeacons(b ...*Beacon) *TagUpdate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID } - return tu.AddSessionIDs(ids...) + return tu.AddBeaconIDs(ids...) } // Mutation returns the TagMutation object of the builder. @@ -60,25 +60,25 @@ func (tu *TagUpdate) Mutation() *TagMutation { return tu.mutation } -// ClearSessions clears all "sessions" edges to the Session entity. -func (tu *TagUpdate) ClearSessions() *TagUpdate { - tu.mutation.ClearSessions() +// ClearBeacons clears all "beacons" edges to the Beacon entity. +func (tu *TagUpdate) ClearBeacons() *TagUpdate { + tu.mutation.ClearBeacons() return tu } -// RemoveSessionIDs removes the "sessions" edge to Session entities by IDs. -func (tu *TagUpdate) RemoveSessionIDs(ids ...int) *TagUpdate { - tu.mutation.RemoveSessionIDs(ids...) +// RemoveBeaconIDs removes the "beacons" edge to Beacon entities by IDs. +func (tu *TagUpdate) RemoveBeaconIDs(ids ...int) *TagUpdate { + tu.mutation.RemoveBeaconIDs(ids...) return tu } -// RemoveSessions removes "sessions" edges to Session entities. -func (tu *TagUpdate) RemoveSessions(s ...*Session) *TagUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// RemoveBeacons removes "beacons" edges to Beacon entities. +func (tu *TagUpdate) RemoveBeacons(b ...*Beacon) *TagUpdate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID } - return tu.RemoveSessionIDs(ids...) + return tu.RemoveBeaconIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. @@ -141,33 +141,33 @@ func (tu *TagUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := tu.mutation.Kind(); ok { _spec.SetField(tag.FieldKind, field.TypeEnum, value) } - if tu.mutation.SessionsCleared() { + if tu.mutation.BeaconsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: tag.SessionsTable, - Columns: tag.SessionsPrimaryKey, + Table: tag.BeaconsTable, + Columns: tag.BeaconsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tu.mutation.RemovedSessionsIDs(); len(nodes) > 0 && !tu.mutation.SessionsCleared() { + if nodes := tu.mutation.RemovedBeaconsIDs(); len(nodes) > 0 && !tu.mutation.BeaconsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: tag.SessionsTable, - Columns: tag.SessionsPrimaryKey, + Table: tag.BeaconsTable, + Columns: tag.BeaconsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } @@ -176,17 +176,17 @@ func (tu *TagUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tu.mutation.SessionsIDs(); len(nodes) > 0 { + if nodes := tu.mutation.BeaconsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: tag.SessionsTable, - Columns: tag.SessionsPrimaryKey, + Table: tag.BeaconsTable, + Columns: tag.BeaconsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } @@ -227,19 +227,19 @@ func (tuo *TagUpdateOne) SetKind(t tag.Kind) *TagUpdateOne { return tuo } -// AddSessionIDs adds the "sessions" edge to the Session entity by IDs. -func (tuo *TagUpdateOne) AddSessionIDs(ids ...int) *TagUpdateOne { - tuo.mutation.AddSessionIDs(ids...) +// AddBeaconIDs adds the "beacons" edge to the Beacon entity by IDs. +func (tuo *TagUpdateOne) AddBeaconIDs(ids ...int) *TagUpdateOne { + tuo.mutation.AddBeaconIDs(ids...) return tuo } -// AddSessions adds the "sessions" edges to the Session entity. -func (tuo *TagUpdateOne) AddSessions(s ...*Session) *TagUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// AddBeacons adds the "beacons" edges to the Beacon entity. +func (tuo *TagUpdateOne) AddBeacons(b ...*Beacon) *TagUpdateOne { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID } - return tuo.AddSessionIDs(ids...) + return tuo.AddBeaconIDs(ids...) } // Mutation returns the TagMutation object of the builder. @@ -247,25 +247,25 @@ func (tuo *TagUpdateOne) Mutation() *TagMutation { return tuo.mutation } -// ClearSessions clears all "sessions" edges to the Session entity. -func (tuo *TagUpdateOne) ClearSessions() *TagUpdateOne { - tuo.mutation.ClearSessions() +// ClearBeacons clears all "beacons" edges to the Beacon entity. +func (tuo *TagUpdateOne) ClearBeacons() *TagUpdateOne { + tuo.mutation.ClearBeacons() return tuo } -// RemoveSessionIDs removes the "sessions" edge to Session entities by IDs. -func (tuo *TagUpdateOne) RemoveSessionIDs(ids ...int) *TagUpdateOne { - tuo.mutation.RemoveSessionIDs(ids...) +// RemoveBeaconIDs removes the "beacons" edge to Beacon entities by IDs. +func (tuo *TagUpdateOne) RemoveBeaconIDs(ids ...int) *TagUpdateOne { + tuo.mutation.RemoveBeaconIDs(ids...) return tuo } -// RemoveSessions removes "sessions" edges to Session entities. -func (tuo *TagUpdateOne) RemoveSessions(s ...*Session) *TagUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +// RemoveBeacons removes "beacons" edges to Beacon entities. +func (tuo *TagUpdateOne) RemoveBeacons(b ...*Beacon) *TagUpdateOne { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID } - return tuo.RemoveSessionIDs(ids...) + return tuo.RemoveBeaconIDs(ids...) } // Where appends a list predicates to the TagUpdate builder. @@ -358,33 +358,33 @@ func (tuo *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) { if value, ok := tuo.mutation.Kind(); ok { _spec.SetField(tag.FieldKind, field.TypeEnum, value) } - if tuo.mutation.SessionsCleared() { + if tuo.mutation.BeaconsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: tag.SessionsTable, - Columns: tag.SessionsPrimaryKey, + Table: tag.BeaconsTable, + Columns: tag.BeaconsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tuo.mutation.RemovedSessionsIDs(); len(nodes) > 0 && !tuo.mutation.SessionsCleared() { + if nodes := tuo.mutation.RemovedBeaconsIDs(); len(nodes) > 0 && !tuo.mutation.BeaconsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: tag.SessionsTable, - Columns: tag.SessionsPrimaryKey, + Table: tag.BeaconsTable, + Columns: tag.BeaconsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } @@ -393,17 +393,17 @@ func (tuo *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tuo.mutation.SessionsIDs(); len(nodes) > 0 { + if nodes := tuo.mutation.BeaconsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, - Table: tag.SessionsTable, - Columns: tag.SessionsPrimaryKey, + Table: tag.BeaconsTable, + Columns: tag.BeaconsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } diff --git a/tavern/ent/task.go b/tavern/ent/task.go index 6878cb4c7..421a7d576 100644 --- a/tavern/ent/task.go +++ b/tavern/ent/task.go @@ -8,8 +8,8 @@ import ( "time" "entgo.io/ent/dialect/sql" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/beacon" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/task" ) @@ -34,17 +34,17 @@ type Task struct { Error string `json:"error,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the TaskQuery when eager-loading is set. - Edges TaskEdges `json:"edges"` - job_tasks *int - task_session *int + Edges TaskEdges `json:"edges"` + quest_tasks *int + task_beacon *int } // TaskEdges holds the relations/edges for other nodes in the graph. type TaskEdges struct { - // Job holds the value of the job edge. - Job *Job `json:"job,omitempty"` - // Session holds the value of the session edge. - Session *Session `json:"session,omitempty"` + // Quest holds the value of the quest edge. + Quest *Quest `json:"quest,omitempty"` + // Beacon holds the value of the beacon edge. + Beacon *Beacon `json:"beacon,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [2]bool @@ -52,30 +52,30 @@ type TaskEdges struct { totalCount [2]map[string]int } -// JobOrErr returns the Job value or an error if the edge +// QuestOrErr returns the Quest value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e TaskEdges) JobOrErr() (*Job, error) { +func (e TaskEdges) QuestOrErr() (*Quest, error) { if e.loadedTypes[0] { - if e.Job == nil { + if e.Quest == nil { // Edge was loaded but was not found. - return nil, &NotFoundError{label: job.Label} + return nil, &NotFoundError{label: quest.Label} } - return e.Job, nil + return e.Quest, nil } - return nil, &NotLoadedError{edge: "job"} + return nil, &NotLoadedError{edge: "quest"} } -// SessionOrErr returns the Session value or an error if the edge +// BeaconOrErr returns the Beacon value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e TaskEdges) SessionOrErr() (*Session, error) { +func (e TaskEdges) BeaconOrErr() (*Beacon, error) { if e.loadedTypes[1] { - if e.Session == nil { + if e.Beacon == nil { // Edge was loaded but was not found. - return nil, &NotFoundError{label: session.Label} + return nil, &NotFoundError{label: beacon.Label} } - return e.Session, nil + return e.Beacon, nil } - return nil, &NotLoadedError{edge: "session"} + return nil, &NotLoadedError{edge: "beacon"} } // scanValues returns the types for scanning values from sql.Rows. @@ -89,9 +89,9 @@ func (*Task) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullString) case task.FieldCreatedAt, task.FieldLastModifiedAt, task.FieldClaimedAt, task.FieldExecStartedAt, task.FieldExecFinishedAt: values[i] = new(sql.NullTime) - case task.ForeignKeys[0]: // job_tasks + case task.ForeignKeys[0]: // quest_tasks values[i] = new(sql.NullInt64) - case task.ForeignKeys[1]: // task_session + case task.ForeignKeys[1]: // task_beacon values[i] = new(sql.NullInt64) default: return nil, fmt.Errorf("unexpected column %q for type Task", columns[i]) @@ -158,31 +158,31 @@ func (t *Task) assignValues(columns []string, values []any) error { } case task.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field job_tasks", value) + return fmt.Errorf("unexpected type %T for edge-field quest_tasks", value) } else if value.Valid { - t.job_tasks = new(int) - *t.job_tasks = int(value.Int64) + t.quest_tasks = new(int) + *t.quest_tasks = int(value.Int64) } case task.ForeignKeys[1]: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field task_session", value) + return fmt.Errorf("unexpected type %T for edge-field task_beacon", value) } else if value.Valid { - t.task_session = new(int) - *t.task_session = int(value.Int64) + t.task_beacon = new(int) + *t.task_beacon = int(value.Int64) } } } return nil } -// QueryJob queries the "job" edge of the Task entity. -func (t *Task) QueryJob() *JobQuery { - return NewTaskClient(t.config).QueryJob(t) +// QueryQuest queries the "quest" edge of the Task entity. +func (t *Task) QueryQuest() *QuestQuery { + return NewTaskClient(t.config).QueryQuest(t) } -// QuerySession queries the "session" edge of the Task entity. -func (t *Task) QuerySession() *SessionQuery { - return NewTaskClient(t.config).QuerySession(t) +// QueryBeacon queries the "beacon" edge of the Task entity. +func (t *Task) QueryBeacon() *BeaconQuery { + return NewTaskClient(t.config).QueryBeacon(t) } // Update returns a builder for updating this Task. diff --git a/tavern/ent/task/task.go b/tavern/ent/task/task.go index f08009b8c..7fc0eaf21 100644 --- a/tavern/ent/task/task.go +++ b/tavern/ent/task/task.go @@ -25,26 +25,26 @@ const ( FieldOutput = "output" // FieldError holds the string denoting the error field in the database. FieldError = "error" - // EdgeJob holds the string denoting the job edge name in mutations. - EdgeJob = "job" - // EdgeSession holds the string denoting the session edge name in mutations. - EdgeSession = "session" + // EdgeQuest holds the string denoting the quest edge name in mutations. + EdgeQuest = "quest" + // EdgeBeacon holds the string denoting the beacon edge name in mutations. + EdgeBeacon = "beacon" // Table holds the table name of the task in the database. Table = "tasks" - // JobTable is the table that holds the job relation/edge. - JobTable = "tasks" - // JobInverseTable is the table name for the Job entity. - // It exists in this package in order to avoid circular dependency with the "job" package. - JobInverseTable = "jobs" - // JobColumn is the table column denoting the job relation/edge. - JobColumn = "job_tasks" - // SessionTable is the table that holds the session relation/edge. - SessionTable = "tasks" - // SessionInverseTable is the table name for the Session entity. - // It exists in this package in order to avoid circular dependency with the "session" package. - SessionInverseTable = "sessions" - // SessionColumn is the table column denoting the session relation/edge. - SessionColumn = "task_session" + // QuestTable is the table that holds the quest relation/edge. + QuestTable = "tasks" + // QuestInverseTable is the table name for the Quest entity. + // It exists in this package in order to avoid circular dependency with the "quest" package. + QuestInverseTable = "quests" + // QuestColumn is the table column denoting the quest relation/edge. + QuestColumn = "quest_tasks" + // BeaconTable is the table that holds the beacon relation/edge. + BeaconTable = "tasks" + // BeaconInverseTable is the table name for the Beacon entity. + // It exists in this package in order to avoid circular dependency with the "beacon" package. + BeaconInverseTable = "beacons" + // BeaconColumn is the table column denoting the beacon relation/edge. + BeaconColumn = "task_beacon" ) // Columns holds all SQL columns for task fields. @@ -62,8 +62,8 @@ var Columns = []string{ // ForeignKeys holds the SQL foreign-keys that are owned by the "tasks" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ - "job_tasks", - "task_session", + "quest_tasks", + "task_beacon", } // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/tavern/ent/task/where.go b/tavern/ent/task/where.go index 6f127e2c8..124c94e6b 100644 --- a/tavern/ent/task/where.go +++ b/tavern/ent/task/where.go @@ -470,24 +470,24 @@ func ErrorContainsFold(v string) predicate.Task { return predicate.Task(sql.FieldContainsFold(FieldError, v)) } -// HasJob applies the HasEdge predicate on the "job" edge. -func HasJob() predicate.Task { +// HasQuest applies the HasEdge predicate on the "quest" edge. +func HasQuest() predicate.Task { return predicate.Task(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, JobTable, JobColumn), + sqlgraph.Edge(sqlgraph.M2O, true, QuestTable, QuestColumn), ) sqlgraph.HasNeighbors(s, step) }) } -// HasJobWith applies the HasEdge predicate on the "job" edge with a given conditions (other predicates). -func HasJobWith(preds ...predicate.Job) predicate.Task { +// HasQuestWith applies the HasEdge predicate on the "quest" edge with a given conditions (other predicates). +func HasQuestWith(preds ...predicate.Quest) predicate.Task { return predicate.Task(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(JobInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, JobTable, JobColumn), + sqlgraph.To(QuestInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, QuestTable, QuestColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { @@ -497,24 +497,24 @@ func HasJobWith(preds ...predicate.Job) predicate.Task { }) } -// HasSession applies the HasEdge predicate on the "session" edge. -func HasSession() predicate.Task { +// HasBeacon applies the HasEdge predicate on the "beacon" edge. +func HasBeacon() predicate.Task { return predicate.Task(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, SessionTable, SessionColumn), + sqlgraph.Edge(sqlgraph.M2O, false, BeaconTable, BeaconColumn), ) sqlgraph.HasNeighbors(s, step) }) } -// HasSessionWith applies the HasEdge predicate on the "session" edge with a given conditions (other predicates). -func HasSessionWith(preds ...predicate.Session) predicate.Task { +// HasBeaconWith applies the HasEdge predicate on the "beacon" edge with a given conditions (other predicates). +func HasBeaconWith(preds ...predicate.Beacon) predicate.Task { return predicate.Task(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(SessionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, SessionTable, SessionColumn), + sqlgraph.To(BeaconInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, BeaconTable, BeaconColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { diff --git a/tavern/ent/task_create.go b/tavern/ent/task_create.go index 62dbb6b41..75b81e169 100644 --- a/tavern/ent/task_create.go +++ b/tavern/ent/task_create.go @@ -10,8 +10,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/job" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/beacon" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/task" ) @@ -120,26 +120,26 @@ func (tc *TaskCreate) SetNillableError(s *string) *TaskCreate { return tc } -// SetJobID sets the "job" edge to the Job entity by ID. -func (tc *TaskCreate) SetJobID(id int) *TaskCreate { - tc.mutation.SetJobID(id) +// SetQuestID sets the "quest" edge to the Quest entity by ID. +func (tc *TaskCreate) SetQuestID(id int) *TaskCreate { + tc.mutation.SetQuestID(id) return tc } -// SetJob sets the "job" edge to the Job entity. -func (tc *TaskCreate) SetJob(j *Job) *TaskCreate { - return tc.SetJobID(j.ID) +// SetQuest sets the "quest" edge to the Quest entity. +func (tc *TaskCreate) SetQuest(q *Quest) *TaskCreate { + return tc.SetQuestID(q.ID) } -// SetSessionID sets the "session" edge to the Session entity by ID. -func (tc *TaskCreate) SetSessionID(id int) *TaskCreate { - tc.mutation.SetSessionID(id) +// SetBeaconID sets the "beacon" edge to the Beacon entity by ID. +func (tc *TaskCreate) SetBeaconID(id int) *TaskCreate { + tc.mutation.SetBeaconID(id) return tc } -// SetSession sets the "session" edge to the Session entity. -func (tc *TaskCreate) SetSession(s *Session) *TaskCreate { - return tc.SetSessionID(s.ID) +// SetBeacon sets the "beacon" edge to the Beacon entity. +func (tc *TaskCreate) SetBeacon(b *Beacon) *TaskCreate { + return tc.SetBeaconID(b.ID) } // Mutation returns the TaskMutation object of the builder. @@ -195,11 +195,11 @@ func (tc *TaskCreate) check() error { if _, ok := tc.mutation.LastModifiedAt(); !ok { return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Task.last_modified_at"`)} } - if _, ok := tc.mutation.JobID(); !ok { - return &ValidationError{Name: "job", err: errors.New(`ent: missing required edge "Task.job"`)} + if _, ok := tc.mutation.QuestID(); !ok { + return &ValidationError{Name: "quest", err: errors.New(`ent: missing required edge "Task.quest"`)} } - if _, ok := tc.mutation.SessionID(); !ok { - return &ValidationError{Name: "session", err: errors.New(`ent: missing required edge "Task.session"`)} + if _, ok := tc.mutation.BeaconID(); !ok { + return &ValidationError{Name: "beacon", err: errors.New(`ent: missing required edge "Task.beacon"`)} } return nil } @@ -255,44 +255,44 @@ func (tc *TaskCreate) createSpec() (*Task, *sqlgraph.CreateSpec) { _spec.SetField(task.FieldError, field.TypeString, value) _node.Error = value } - if nodes := tc.mutation.JobIDs(); len(nodes) > 0 { + if nodes := tc.mutation.QuestIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: task.JobTable, - Columns: []string{task.JobColumn}, + Table: task.QuestTable, + Columns: []string{task.QuestColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: job.FieldID, + Column: quest.FieldID, }, }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.job_tasks = &nodes[0] + _node.quest_tasks = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := tc.mutation.SessionIDs(); len(nodes) > 0 { + if nodes := tc.mutation.BeaconIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: task.SessionTable, - Columns: []string{task.SessionColumn}, + Table: task.BeaconTable, + Columns: []string{task.BeaconColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.task_session = &nodes[0] + _node.task_beacon = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec diff --git a/tavern/ent/task_query.go b/tavern/ent/task_query.go index a2a8ce8ac..860d3f31e 100644 --- a/tavern/ent/task_query.go +++ b/tavern/ent/task_query.go @@ -10,24 +10,24 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/job" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/task" ) // TaskQuery is the builder for querying Task entities. type TaskQuery struct { config - ctx *QueryContext - order []OrderFunc - inters []Interceptor - predicates []predicate.Task - withJob *JobQuery - withSession *SessionQuery - withFKs bool - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Task) error + ctx *QueryContext + order []OrderFunc + inters []Interceptor + predicates []predicate.Task + withQuest *QuestQuery + withBeacon *BeaconQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Task) error // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -64,9 +64,9 @@ func (tq *TaskQuery) Order(o ...OrderFunc) *TaskQuery { return tq } -// QueryJob chains the current query on the "job" edge. -func (tq *TaskQuery) QueryJob() *JobQuery { - query := (&JobClient{config: tq.config}).Query() +// QueryQuest chains the current query on the "quest" edge. +func (tq *TaskQuery) QueryQuest() *QuestQuery { + query := (&QuestClient{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 @@ -77,8 +77,8 @@ func (tq *TaskQuery) QueryJob() *JobQuery { } step := sqlgraph.NewStep( sqlgraph.From(task.Table, task.FieldID, selector), - sqlgraph.To(job.Table, job.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, task.JobTable, task.JobColumn), + sqlgraph.To(quest.Table, quest.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, task.QuestTable, task.QuestColumn), ) fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) return fromU, nil @@ -86,9 +86,9 @@ func (tq *TaskQuery) QueryJob() *JobQuery { return query } -// QuerySession chains the current query on the "session" edge. -func (tq *TaskQuery) QuerySession() *SessionQuery { - query := (&SessionClient{config: tq.config}).Query() +// QueryBeacon chains the current query on the "beacon" edge. +func (tq *TaskQuery) QueryBeacon() *BeaconQuery { + query := (&BeaconClient{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 @@ -99,8 +99,8 @@ func (tq *TaskQuery) QuerySession() *SessionQuery { } step := sqlgraph.NewStep( sqlgraph.From(task.Table, task.FieldID, selector), - sqlgraph.To(session.Table, session.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, task.SessionTable, task.SessionColumn), + sqlgraph.To(beacon.Table, beacon.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, task.BeaconTable, task.BeaconColumn), ) fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) return fromU, nil @@ -295,38 +295,38 @@ func (tq *TaskQuery) Clone() *TaskQuery { return nil } return &TaskQuery{ - config: tq.config, - ctx: tq.ctx.Clone(), - order: append([]OrderFunc{}, tq.order...), - inters: append([]Interceptor{}, tq.inters...), - predicates: append([]predicate.Task{}, tq.predicates...), - withJob: tq.withJob.Clone(), - withSession: tq.withSession.Clone(), + config: tq.config, + ctx: tq.ctx.Clone(), + order: append([]OrderFunc{}, tq.order...), + inters: append([]Interceptor{}, tq.inters...), + predicates: append([]predicate.Task{}, tq.predicates...), + withQuest: tq.withQuest.Clone(), + withBeacon: tq.withBeacon.Clone(), // clone intermediate query. sql: tq.sql.Clone(), path: tq.path, } } -// WithJob tells the query-builder to eager-load the nodes that are connected to -// the "job" edge. The optional arguments are used to configure the query builder of the edge. -func (tq *TaskQuery) WithJob(opts ...func(*JobQuery)) *TaskQuery { - query := (&JobClient{config: tq.config}).Query() +// WithQuest tells the query-builder to eager-load the nodes that are connected to +// the "quest" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TaskQuery) WithQuest(opts ...func(*QuestQuery)) *TaskQuery { + query := (&QuestClient{config: tq.config}).Query() for _, opt := range opts { opt(query) } - tq.withJob = query + tq.withQuest = query return tq } -// WithSession tells the query-builder to eager-load the nodes that are connected to -// the "session" edge. The optional arguments are used to configure the query builder of the edge. -func (tq *TaskQuery) WithSession(opts ...func(*SessionQuery)) *TaskQuery { - query := (&SessionClient{config: tq.config}).Query() +// WithBeacon tells the query-builder to eager-load the nodes that are connected to +// the "beacon" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TaskQuery) WithBeacon(opts ...func(*BeaconQuery)) *TaskQuery { + query := (&BeaconClient{config: tq.config}).Query() for _, opt := range opts { opt(query) } - tq.withSession = query + tq.withBeacon = query return tq } @@ -410,11 +410,11 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e withFKs = tq.withFKs _spec = tq.querySpec() loadedTypes = [2]bool{ - tq.withJob != nil, - tq.withSession != nil, + tq.withQuest != nil, + tq.withBeacon != nil, } ) - if tq.withJob != nil || tq.withSession != nil { + if tq.withQuest != nil || tq.withBeacon != nil { withFKs = true } if withFKs { @@ -441,15 +441,15 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e if len(nodes) == 0 { return nodes, nil } - if query := tq.withJob; query != nil { - if err := tq.loadJob(ctx, query, nodes, nil, - func(n *Task, e *Job) { n.Edges.Job = e }); err != nil { + if query := tq.withQuest; query != nil { + if err := tq.loadQuest(ctx, query, nodes, nil, + func(n *Task, e *Quest) { n.Edges.Quest = e }); err != nil { return nil, err } } - if query := tq.withSession; query != nil { - if err := tq.loadSession(ctx, query, nodes, nil, - func(n *Task, e *Session) { n.Edges.Session = e }); err != nil { + if query := tq.withBeacon; query != nil { + if err := tq.loadBeacon(ctx, query, nodes, nil, + func(n *Task, e *Beacon) { n.Edges.Beacon = e }); err != nil { return nil, err } } @@ -461,14 +461,14 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e return nodes, nil } -func (tq *TaskQuery) loadJob(ctx context.Context, query *JobQuery, nodes []*Task, init func(*Task), assign func(*Task, *Job)) error { +func (tq *TaskQuery) loadQuest(ctx context.Context, query *QuestQuery, nodes []*Task, init func(*Task), assign func(*Task, *Quest)) error { ids := make([]int, 0, len(nodes)) nodeids := make(map[int][]*Task) for i := range nodes { - if nodes[i].job_tasks == nil { + if nodes[i].quest_tasks == nil { continue } - fk := *nodes[i].job_tasks + fk := *nodes[i].quest_tasks if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -477,7 +477,7 @@ func (tq *TaskQuery) loadJob(ctx context.Context, query *JobQuery, nodes []*Task if len(ids) == 0 { return nil } - query.Where(job.IDIn(ids...)) + query.Where(quest.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -485,7 +485,7 @@ func (tq *TaskQuery) loadJob(ctx context.Context, query *JobQuery, nodes []*Task for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "job_tasks" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "quest_tasks" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) @@ -493,14 +493,14 @@ func (tq *TaskQuery) loadJob(ctx context.Context, query *JobQuery, nodes []*Task } return nil } -func (tq *TaskQuery) loadSession(ctx context.Context, query *SessionQuery, nodes []*Task, init func(*Task), assign func(*Task, *Session)) error { +func (tq *TaskQuery) loadBeacon(ctx context.Context, query *BeaconQuery, nodes []*Task, init func(*Task), assign func(*Task, *Beacon)) error { ids := make([]int, 0, len(nodes)) nodeids := make(map[int][]*Task) for i := range nodes { - if nodes[i].task_session == nil { + if nodes[i].task_beacon == nil { continue } - fk := *nodes[i].task_session + fk := *nodes[i].task_beacon if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -509,7 +509,7 @@ func (tq *TaskQuery) loadSession(ctx context.Context, query *SessionQuery, nodes if len(ids) == 0 { return nil } - query.Where(session.IDIn(ids...)) + query.Where(beacon.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -517,7 +517,7 @@ func (tq *TaskQuery) loadSession(ctx context.Context, query *SessionQuery, nodes for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "task_session" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "task_beacon" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) diff --git a/tavern/ent/task_update.go b/tavern/ent/task_update.go index 643652455..8039de4c8 100644 --- a/tavern/ent/task_update.go +++ b/tavern/ent/task_update.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/kcarretto/realm/tavern/ent/job" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/predicate" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/quest" "github.com/kcarretto/realm/tavern/ent/task" ) @@ -136,26 +136,26 @@ func (tu *TaskUpdate) ClearError() *TaskUpdate { return tu } -// SetJobID sets the "job" edge to the Job entity by ID. -func (tu *TaskUpdate) SetJobID(id int) *TaskUpdate { - tu.mutation.SetJobID(id) +// SetQuestID sets the "quest" edge to the Quest entity by ID. +func (tu *TaskUpdate) SetQuestID(id int) *TaskUpdate { + tu.mutation.SetQuestID(id) return tu } -// SetJob sets the "job" edge to the Job entity. -func (tu *TaskUpdate) SetJob(j *Job) *TaskUpdate { - return tu.SetJobID(j.ID) +// SetQuest sets the "quest" edge to the Quest entity. +func (tu *TaskUpdate) SetQuest(q *Quest) *TaskUpdate { + return tu.SetQuestID(q.ID) } -// SetSessionID sets the "session" edge to the Session entity by ID. -func (tu *TaskUpdate) SetSessionID(id int) *TaskUpdate { - tu.mutation.SetSessionID(id) +// SetBeaconID sets the "beacon" edge to the Beacon entity by ID. +func (tu *TaskUpdate) SetBeaconID(id int) *TaskUpdate { + tu.mutation.SetBeaconID(id) return tu } -// SetSession sets the "session" edge to the Session entity. -func (tu *TaskUpdate) SetSession(s *Session) *TaskUpdate { - return tu.SetSessionID(s.ID) +// SetBeacon sets the "beacon" edge to the Beacon entity. +func (tu *TaskUpdate) SetBeacon(b *Beacon) *TaskUpdate { + return tu.SetBeaconID(b.ID) } // Mutation returns the TaskMutation object of the builder. @@ -163,15 +163,15 @@ func (tu *TaskUpdate) Mutation() *TaskMutation { return tu.mutation } -// ClearJob clears the "job" edge to the Job entity. -func (tu *TaskUpdate) ClearJob() *TaskUpdate { - tu.mutation.ClearJob() +// ClearQuest clears the "quest" edge to the Quest entity. +func (tu *TaskUpdate) ClearQuest() *TaskUpdate { + tu.mutation.ClearQuest() return tu } -// ClearSession clears the "session" edge to the Session entity. -func (tu *TaskUpdate) ClearSession() *TaskUpdate { - tu.mutation.ClearSession() +// ClearBeacon clears the "beacon" edge to the Beacon entity. +func (tu *TaskUpdate) ClearBeacon() *TaskUpdate { + tu.mutation.ClearBeacon() return tu } @@ -213,11 +213,11 @@ func (tu *TaskUpdate) defaults() { // check runs all checks and user-defined validators on the builder. func (tu *TaskUpdate) check() error { - if _, ok := tu.mutation.JobID(); tu.mutation.JobCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Task.job"`) + if _, ok := tu.mutation.QuestID(); tu.mutation.QuestCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Task.quest"`) } - if _, ok := tu.mutation.SessionID(); tu.mutation.SessionCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Task.session"`) + if _, ok := tu.mutation.BeaconID(); tu.mutation.BeaconCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Task.beacon"`) } return nil } @@ -267,33 +267,33 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { if tu.mutation.ErrorCleared() { _spec.ClearField(task.FieldError, field.TypeString) } - if tu.mutation.JobCleared() { + if tu.mutation.QuestCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: task.JobTable, - Columns: []string{task.JobColumn}, + Table: task.QuestTable, + Columns: []string{task.QuestColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: job.FieldID, + Column: quest.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tu.mutation.JobIDs(); len(nodes) > 0 { + if nodes := tu.mutation.QuestIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: task.JobTable, - Columns: []string{task.JobColumn}, + Table: task.QuestTable, + Columns: []string{task.QuestColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: job.FieldID, + Column: quest.FieldID, }, }, } @@ -302,33 +302,33 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if tu.mutation.SessionCleared() { + if tu.mutation.BeaconCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: task.SessionTable, - Columns: []string{task.SessionColumn}, + Table: task.BeaconTable, + Columns: []string{task.BeaconColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tu.mutation.SessionIDs(); len(nodes) > 0 { + if nodes := tu.mutation.BeaconIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: task.SessionTable, - Columns: []string{task.SessionColumn}, + Table: task.BeaconTable, + Columns: []string{task.BeaconColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } @@ -463,26 +463,26 @@ func (tuo *TaskUpdateOne) ClearError() *TaskUpdateOne { return tuo } -// SetJobID sets the "job" edge to the Job entity by ID. -func (tuo *TaskUpdateOne) SetJobID(id int) *TaskUpdateOne { - tuo.mutation.SetJobID(id) +// SetQuestID sets the "quest" edge to the Quest entity by ID. +func (tuo *TaskUpdateOne) SetQuestID(id int) *TaskUpdateOne { + tuo.mutation.SetQuestID(id) return tuo } -// SetJob sets the "job" edge to the Job entity. -func (tuo *TaskUpdateOne) SetJob(j *Job) *TaskUpdateOne { - return tuo.SetJobID(j.ID) +// SetQuest sets the "quest" edge to the Quest entity. +func (tuo *TaskUpdateOne) SetQuest(q *Quest) *TaskUpdateOne { + return tuo.SetQuestID(q.ID) } -// SetSessionID sets the "session" edge to the Session entity by ID. -func (tuo *TaskUpdateOne) SetSessionID(id int) *TaskUpdateOne { - tuo.mutation.SetSessionID(id) +// SetBeaconID sets the "beacon" edge to the Beacon entity by ID. +func (tuo *TaskUpdateOne) SetBeaconID(id int) *TaskUpdateOne { + tuo.mutation.SetBeaconID(id) return tuo } -// SetSession sets the "session" edge to the Session entity. -func (tuo *TaskUpdateOne) SetSession(s *Session) *TaskUpdateOne { - return tuo.SetSessionID(s.ID) +// SetBeacon sets the "beacon" edge to the Beacon entity. +func (tuo *TaskUpdateOne) SetBeacon(b *Beacon) *TaskUpdateOne { + return tuo.SetBeaconID(b.ID) } // Mutation returns the TaskMutation object of the builder. @@ -490,15 +490,15 @@ func (tuo *TaskUpdateOne) Mutation() *TaskMutation { return tuo.mutation } -// ClearJob clears the "job" edge to the Job entity. -func (tuo *TaskUpdateOne) ClearJob() *TaskUpdateOne { - tuo.mutation.ClearJob() +// ClearQuest clears the "quest" edge to the Quest entity. +func (tuo *TaskUpdateOne) ClearQuest() *TaskUpdateOne { + tuo.mutation.ClearQuest() return tuo } -// ClearSession clears the "session" edge to the Session entity. -func (tuo *TaskUpdateOne) ClearSession() *TaskUpdateOne { - tuo.mutation.ClearSession() +// ClearBeacon clears the "beacon" edge to the Beacon entity. +func (tuo *TaskUpdateOne) ClearBeacon() *TaskUpdateOne { + tuo.mutation.ClearBeacon() return tuo } @@ -553,11 +553,11 @@ func (tuo *TaskUpdateOne) defaults() { // check runs all checks and user-defined validators on the builder. func (tuo *TaskUpdateOne) check() error { - if _, ok := tuo.mutation.JobID(); tuo.mutation.JobCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Task.job"`) + if _, ok := tuo.mutation.QuestID(); tuo.mutation.QuestCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Task.quest"`) } - if _, ok := tuo.mutation.SessionID(); tuo.mutation.SessionCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Task.session"`) + if _, ok := tuo.mutation.BeaconID(); tuo.mutation.BeaconCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Task.beacon"`) } return nil } @@ -624,33 +624,33 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) if tuo.mutation.ErrorCleared() { _spec.ClearField(task.FieldError, field.TypeString) } - if tuo.mutation.JobCleared() { + if tuo.mutation.QuestCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: task.JobTable, - Columns: []string{task.JobColumn}, + Table: task.QuestTable, + Columns: []string{task.QuestColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: job.FieldID, + Column: quest.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tuo.mutation.JobIDs(); len(nodes) > 0 { + if nodes := tuo.mutation.QuestIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: task.JobTable, - Columns: []string{task.JobColumn}, + Table: task.QuestTable, + Columns: []string{task.QuestColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: job.FieldID, + Column: quest.FieldID, }, }, } @@ -659,33 +659,33 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if tuo.mutation.SessionCleared() { + if tuo.mutation.BeaconCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: task.SessionTable, - Columns: []string{task.SessionColumn}, + Table: task.BeaconTable, + Columns: []string{task.BeaconColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := tuo.mutation.SessionIDs(); len(nodes) > 0 { + if nodes := tuo.mutation.BeaconIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: task.SessionTable, - Columns: []string{task.SessionColumn}, + Table: task.BeaconTable, + Columns: []string{task.BeaconColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: &sqlgraph.FieldSpec{ Type: field.TypeInt, - Column: session.FieldID, + Column: beacon.FieldID, }, }, } diff --git a/tavern/ent/tx.go b/tavern/ent/tx.go index 2a36e3f29..edcfe2176 100644 --- a/tavern/ent/tx.go +++ b/tavern/ent/tx.go @@ -12,12 +12,12 @@ import ( // Tx is a transactional client that is created by calling Client.Tx(). type Tx struct { config + // Beacon is the client for interacting with the Beacon builders. + Beacon *BeaconClient // File is the client for interacting with the File builders. File *FileClient - // Job is the client for interacting with the Job builders. - Job *JobClient - // Session is the client for interacting with the Session builders. - Session *SessionClient + // Quest is the client for interacting with the Quest builders. + Quest *QuestClient // Tag is the client for interacting with the Tag builders. Tag *TagClient // Task is the client for interacting with the Task builders. @@ -157,9 +157,9 @@ func (tx *Tx) Client() *Client { } func (tx *Tx) init() { + tx.Beacon = NewBeaconClient(tx.config) tx.File = NewFileClient(tx.config) - tx.Job = NewJobClient(tx.config) - tx.Session = NewSessionClient(tx.config) + tx.Quest = NewQuestClient(tx.config) tx.Tag = NewTagClient(tx.config) tx.Task = NewTaskClient(tx.config) tx.Tome = NewTomeClient(tx.config) @@ -173,7 +173,7 @@ func (tx *Tx) init() { // of them in order to commit or rollback the transaction. // // If a closed transaction is embedded in one of the generated entities, and the entity -// applies a query, for example: File.QueryXXX(), the query will be executed +// applies a query, for example: Beacon.QueryXXX(), the query will be executed // through the driver which created this transaction. // // Note that txDriver is not goroutine safe. diff --git a/tavern/graphql/session_test.go b/tavern/graphql/beacon_test.go similarity index 64% rename from tavern/graphql/session_test.go rename to tavern/graphql/beacon_test.go index 799512677..e44a484d3 100644 --- a/tavern/graphql/session_test.go +++ b/tavern/graphql/beacon_test.go @@ -10,15 +10,15 @@ import ( "github.com/99designs/gqlgen/graphql/handler" "github.com/kcarretto/realm/tavern/auth" "github.com/kcarretto/realm/tavern/ent" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/enttest" - "github.com/kcarretto/realm/tavern/ent/session" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/kcarretto/realm/tavern/graphql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func TestSessionMutations(t *testing.T) { +func TestBeaconMutations(t *testing.T) { // Setup ctx := context.Background() graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") @@ -37,8 +37,8 @@ func TestSessionMutations(t *testing.T) { SetName("TestTag2"). SaveX(ctx), } - testSessions := []*ent.Session{ - graph.Session.Create(). + testBeacons := []*ent.Beacon{ + graph.Beacon.Create(). SetPrincipal("admin"). SetAgentIdentifier("TEST"). SetIdentifier("SOME_ID"). @@ -46,7 +46,7 @@ func TestSessionMutations(t *testing.T) { SetHostname("SOME_HOSTNAME"). SetLastSeenAt(time.Now().Add(-10 * time.Minute)). SaveX(ctx), - graph.Session.Create(). + graph.Beacon.Create(). SetIdentifier("ANOTHER_ID"). SetHostname("BAD_HOSTNAME"). SetLastSeenAt(time.Now().Add(-10 * time.Minute)). @@ -58,14 +58,14 @@ func TestSessionMutations(t *testing.T) { SetDescription("Ensures the world feels greeted"). SetEldritch(`print("Hello World!")`). SaveX(ctx) - testJob := graph.Job.Create(). + testQuest := graph.Quest.Create(). SetName("howdy-ho"). SetTome(testTome). SaveX(ctx) testTasks := []*ent.Task{ graph.Task.Create(). - SetJob(testJob). - SetSession(testSessions[0]). + SetQuest(testQuest). + SetBeacon(testBeacons[0]). SaveX(ctx), } @@ -75,7 +75,7 @@ func TestSessionMutations(t *testing.T) { mutation newClaimTasksTest($input: ClaimTasksInput!) { claimTasks(input: $input) { id - job { + quest { id } } @@ -85,10 +85,10 @@ mutation newClaimTasksTest($input: ClaimTasksInput!) { // Make our request to the GraphQL API var resp struct { ClaimTasks []struct { - ID string - Job struct { + ID string + Quest struct { ID string - } `json:"job"` + } `json:"quest"` } } err := gqlClient.Post(mut, &resp, client.Var("input", input)) @@ -105,50 +105,50 @@ mutation newClaimTasksTest($input: ClaimTasksInput!) { } /* - * Test when the `claimTasks` mutation is run by a session that does not exist. + * Test when the `claimTasks` mutation is run by a beacon that does not exist. * - * Expected that the session is created, but no tasks are returned. + * Expected that the beacon is created, but no tasks are returned. */ - t.Run("NewSession", func(t *testing.T) { + t.Run("NewBeacon", func(t *testing.T) { expectedIdentifier := "NEW_ID" expected := map[string]any{ - "principal": "newuser", - "hostname": "NEW_HOSTNAME", - "hostPlatform": session.HostPlatformWindows, - "sessionIdentifier": expectedIdentifier, - "hostIdentifier": "NEW_HOST_ID", - "agentIdentifier": "NEW_AGENT_ID", + "principal": "newuser", + "hostname": "NEW_HOSTNAME", + "hostPlatform": beacon.HostPlatformWindows, + "beaconIdentifier": expectedIdentifier, + "hostIdentifier": "NEW_HOST_ID", + "agentIdentifier": "NEW_AGENT_ID", } ids, err := claimTasks(expected) require.NoError(t, err) assert.Empty(t, ids) - testSession, err := graph.Session.Query(). - Where(session.Identifier(expectedIdentifier)). + testBeacon, err := graph.Beacon.Query(). + Where(beacon.Identifier(expectedIdentifier)). Only(ctx) require.NoError(t, err) - assert.NotNil(t, testSession) - assert.NotZero(t, testSession.LastSeenAt) - assert.Equal(t, expected["principal"], testSession.Principal) - assert.Equal(t, expected["hostname"], testSession.Hostname) - assert.Equal(t, expected["sessionIdentifier"], testSession.Identifier) - assert.Equal(t, expected["hostIdentifier"], testSession.HostIdentifier) - assert.Equal(t, expected["agentIdentifier"], testSession.AgentIdentifier) + assert.NotNil(t, testBeacon) + assert.NotZero(t, testBeacon.LastSeenAt) + assert.Equal(t, expected["principal"], testBeacon.Principal) + assert.Equal(t, expected["hostname"], testBeacon.Hostname) + assert.Equal(t, expected["beaconIdentifier"], testBeacon.Identifier) + assert.Equal(t, expected["hostIdentifier"], testBeacon.HostIdentifier) + assert.Equal(t, expected["agentIdentifier"], testBeacon.AgentIdentifier) }) /* - * Test when the `claimTasks` mutation is run by a session that already exists. + * Test when the `claimTasks` mutation is run by a beacon that already exists. * - * Expected that the session is updated, and our test task is returned. + * Expected that the beacon is updated, and our test task is returned. */ - t.Run("ExistingSession", func(t *testing.T) { + t.Run("ExistingBeacon", func(t *testing.T) { expected := map[string]any{ - "principal": "admin", - "hostname": "SOME_HOSTNAME", - "hostPlatform": session.HostPlatformMacOS, - "hostPrimaryIP": "10.0.0.1", - "sessionIdentifier": "SOME_ID", - "hostIdentifier": "SOME_HOST_ID", - "agentIdentifier": "SOME_AGENT_ID", + "principal": "admin", + "hostname": "SOME_HOSTNAME", + "hostPlatform": beacon.HostPlatformMacOS, + "hostPrimaryIP": "10.0.0.1", + "beaconIdentifier": "SOME_ID", + "hostIdentifier": "SOME_HOST_ID", + "agentIdentifier": "SOME_AGENT_ID", } ids, err := claimTasks(expected) require.NoError(t, err) @@ -157,17 +157,17 @@ mutation newClaimTasksTest($input: ClaimTasksInput!) { testTask := graph.Task.GetX(ctx, testTasks[0].ID) assert.NotZero(t, testTask.ClaimedAt) - testSession, err := testTask.Session(ctx) + testBeacon, err := testTask.Beacon(ctx) require.NoError(t, err) - assert.Equal(t, testSessions[0].ID, testSession.ID) - assert.NotZero(t, testSession.LastSeenAt) - assert.Equal(t, expected["principal"], testSession.Principal) - assert.Equal(t, expected["hostname"], testSession.Hostname) - assert.Equal(t, expected["sessionIdentifier"], testSession.Identifier) - assert.Equal(t, expected["hostIdentifier"], testSession.HostIdentifier) - assert.Equal(t, expected["agentIdentifier"], testSession.AgentIdentifier) - assert.Equal(t, expected["hostPlatform"], testSession.HostPlatform) - assert.Equal(t, expected["hostPrimaryIP"], testSession.HostPrimaryIP) + assert.Equal(t, testBeacons[0].ID, testBeacon.ID) + assert.NotZero(t, testBeacon.LastSeenAt) + assert.Equal(t, expected["principal"], testBeacon.Principal) + assert.Equal(t, expected["hostname"], testBeacon.Hostname) + assert.Equal(t, expected["beaconIdentifier"], testBeacon.Identifier) + assert.Equal(t, expected["hostIdentifier"], testBeacon.HostIdentifier) + assert.Equal(t, expected["agentIdentifier"], testBeacon.AgentIdentifier) + assert.Equal(t, expected["hostPlatform"], testBeacon.HostPlatform) + assert.Equal(t, expected["hostPrimaryIP"], testBeacon.HostPrimaryIP) }) }) @@ -249,54 +249,54 @@ mutation newSubmitTaskResultTest($input: SubmitTaskResultInput!) { }) }) - t.Run("UpdateSession", func(t *testing.T) { - // Define the UpdateSession mutation + t.Run("UpdateBeacon", func(t *testing.T) { + // Define the UpdateBeacon mutation mut := ` -mutation newUpdateSessionTest($sessionID: ID!, $input: UpdateSessionInput!) { - updateSession(sessionID: $sessionID, input: $input) { +mutation newUpdateBeaconTest($beaconID: ID!, $input: UpdateBeaconInput!) { + updateBeacon(beaconID: $beaconID, input: $input) { id } }` // Create a closure to execute the mutation - updateSession := func(sessionID int, input map[string]any) (int, error) { + updateBeacon := func(beaconID int, input map[string]any) (int, error) { // Make our request to the GraphQL API var resp struct { - UpdateSession struct{ ID string } + UpdateBeacon struct{ ID string } } err := gqlClient.Post( mut, &resp, - client.Var("sessionID", sessionID), + client.Var("beaconID", beaconID), client.Var("input", input), ) if err != nil { return 0, err } - return convertID(resp.UpdateSession.ID), nil + return convertID(resp.UpdateBeacon.ID), nil } /* - * Test updating tags and changing hostname for an existing session. + * Test updating tags and changing hostname for an existing beacon. * - * Expected that the session is updated with the new set of tags and a better hostname. + * Expected that the beacon is updated with the new set of tags and a better hostname. */ - t.Run("UpdateSession", func(t *testing.T) { + t.Run("UpdateBeacon", func(t *testing.T) { expected := map[string]any{ "hostname": "BETTER_HOSTNAME", "addTagIDs": testTags[0].ID, "removeTagIDs": testTags[1].ID, } - id, err := updateSession(testSessions[1].ID, expected) + id, err := updateBeacon(testBeacons[1].ID, expected) require.NoError(t, err) require.NotZero(t, id) - assert.Equal(t, testSessions[1].ID, id) - testSession := graph.Session.GetX(ctx, id) - assert.Equal(t, expected["hostname"], testSession.Hostname) - testSessionTags, err := testSession.Tags(ctx) + assert.Equal(t, testBeacons[1].ID, id) + testBeacon := graph.Beacon.GetX(ctx, id) + assert.Equal(t, expected["hostname"], testBeacon.Hostname) + testBeaconTags, err := testBeacon.Tags(ctx) require.NoError(t, err) - assert.Len(t, testSessionTags, 1) - assert.Equal(t, testTags[0].ID, testSessionTags[0].ID) + assert.Len(t, testBeaconTags, 1) + assert.Equal(t, testTags[0].ID, testBeaconTags[0].ID) }) }) } diff --git a/tavern/graphql/generated/ent.generated.go b/tavern/graphql/generated/ent.generated.go index 25d128ad2..8a288807d 100644 --- a/tavern/graphql/generated/ent.generated.go +++ b/tavern/graphql/generated/ent.generated.go @@ -14,7 +14,7 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/kcarretto/realm/tavern/ent" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/tag" "github.com/vektah/gqlparser/v2/ast" ) @@ -25,8 +25,8 @@ type QueryResolver interface { Node(ctx context.Context, id int) (ent.Noder, error) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) Files(ctx context.Context, where *ent.FileWhereInput) ([]*ent.File, error) - Jobs(ctx context.Context, where *ent.JobWhereInput) ([]*ent.Job, error) - Sessions(ctx context.Context, where *ent.SessionWhereInput) ([]*ent.Session, error) + Quests(ctx context.Context, where *ent.QuestWhereInput) ([]*ent.Quest, error) + Beacons(ctx context.Context, where *ent.BeaconWhereInput) ([]*ent.Beacon, error) Tags(ctx context.Context, where *ent.TagWhereInput) ([]*ent.Tag, error) Tomes(ctx context.Context, where *ent.TomeWhereInput) ([]*ent.Tome, error) Users(ctx context.Context, where *ent.UserWhereInput) ([]*ent.User, error) @@ -51,13 +51,13 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (ec *executionContext) field_Query_files_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_beacons_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *ent.FileWhereInput + var arg0 *ent.BeaconWhereInput if tmp, ok := rawArgs["where"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg0, err = ec.unmarshalOFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx, tmp) + arg0, err = ec.unmarshalOBeaconWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInput(ctx, tmp) if err != nil { return nil, err } @@ -66,13 +66,13 @@ func (ec *executionContext) field_Query_files_args(ctx context.Context, rawArgs return args, nil } -func (ec *executionContext) field_Query_jobs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_files_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *ent.JobWhereInput + var arg0 *ent.FileWhereInput if tmp, ok := rawArgs["where"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg0, err = ec.unmarshalOJobWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInput(ctx, tmp) + arg0, err = ec.unmarshalOFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx, tmp) if err != nil { return nil, err } @@ -111,13 +111,13 @@ func (ec *executionContext) field_Query_nodes_args(ctx context.Context, rawArgs return args, nil } -func (ec *executionContext) field_Query_sessions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_quests_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *ent.SessionWhereInput + var arg0 *ent.QuestWhereInput if tmp, ok := rawArgs["where"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg0, err = ec.unmarshalOSessionWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInput(ctx, tmp) + arg0, err = ec.unmarshalOQuestWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInput(ctx, tmp) if err != nil { return nil, err } @@ -179,8 +179,8 @@ func (ec *executionContext) field_Query_users_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -func (ec *executionContext) _File_id(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_File_id(ctx, field) +func (ec *executionContext) _Beacon_id(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_id(ctx, field) if err != nil { return graphql.Null } @@ -210,9 +210,9 @@ func (ec *executionContext) _File_id(ctx context.Context, field graphql.Collecte return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_File_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "File", + Object: "Beacon", Field: field, IsMethod: false, IsResolver: false, @@ -223,8 +223,8 @@ func (ec *executionContext) fieldContext_File_id(ctx context.Context, field grap return fc, nil } -func (ec *executionContext) _File_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_File_createdAt(ctx, field) +func (ec *executionContext) _Beacon_name(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_name(ctx, field) if err != nil { return graphql.Null } @@ -237,7 +237,7 @@ func (ec *executionContext) _File_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 + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -249,26 +249,26 @@ func (ec *executionContext) _File_createdAt(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(string) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_File_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "File", + Object: "Beacon", 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) _File_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_File_lastModifiedAt(ctx, field) +func (ec *executionContext) _Beacon_principal(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_principal(ctx, field) if err != nil { return graphql.Null } @@ -281,38 +281,35 @@ func (ec *executionContext) _File_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 + return obj.Principal, 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_File_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_principal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "File", + Object: "Beacon", 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) _File_name(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_File_name(ctx, field) +func (ec *executionContext) _Beacon_hostname(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_hostname(ctx, field) if err != nil { return graphql.Null } @@ -325,26 +322,23 @@ func (ec *executionContext) _File_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.Hostname, 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_File_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_hostname(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "File", + Object: "Beacon", Field: field, IsMethod: false, IsResolver: false, @@ -355,8 +349,8 @@ func (ec *executionContext) fieldContext_File_name(ctx context.Context, field gr return fc, nil } -func (ec *executionContext) _File_size(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_File_size(ctx, field) +func (ec *executionContext) _Beacon_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_identifier(ctx, field) if err != nil { return graphql.Null } @@ -369,7 +363,7 @@ func (ec *executionContext) _File_size(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.Size, nil + return obj.Identifier, nil }) if err != nil { ec.Error(ctx, err) @@ -381,26 +375,26 @@ func (ec *executionContext) _File_size(ctx context.Context, field graphql.Collec } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_File_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_identifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "File", + Object: "Beacon", 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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _File_hash(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_File_hash(ctx, field) +func (ec *executionContext) _Beacon_agentIdentifier(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_agentIdentifier(ctx, field) if err != nil { return graphql.Null } @@ -413,26 +407,23 @@ func (ec *executionContext) _File_hash(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.Hash, nil + return obj.AgentIdentifier, 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_File_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_agentIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "File", + Object: "Beacon", Field: field, IsMethod: false, IsResolver: false, @@ -443,8 +434,8 @@ func (ec *executionContext) fieldContext_File_hash(ctx context.Context, field gr return fc, nil } -func (ec *executionContext) _Job_id(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_id(ctx, field) +func (ec *executionContext) _Beacon_hostIdentifier(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_hostIdentifier(ctx, field) if err != nil { return graphql.Null } @@ -457,38 +448,35 @@ func (ec *executionContext) _Job_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 + return obj.HostIdentifier, 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.marshalNID2int(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Job_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_hostIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "Beacon", 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) _Job_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_createdAt(ctx, field) +func (ec *executionContext) _Beacon_hostPrimaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_hostPrimaryIP(ctx, field) if err != nil { return graphql.Null } @@ -501,38 +489,35 @@ func (ec *executionContext) _Job_createdAt(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.CreatedAt, nil + return obj.HostPrimaryIP, 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_Job_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_hostPrimaryIP(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "Beacon", 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) _Job_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_lastModifiedAt(ctx, field) +func (ec *executionContext) _Beacon_hostPlatform(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_hostPlatform(ctx, field) if err != nil { return graphql.Null } @@ -545,7 +530,7 @@ func (ec *executionContext) _Job_lastModifiedAt(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.LastModifiedAt, nil + return obj.HostPlatform, nil }) if err != nil { ec.Error(ctx, err) @@ -557,26 +542,26 @@ func (ec *executionContext) _Job_lastModifiedAt(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(beacon.HostPlatform) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNBeaconHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Job_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_hostPlatform(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "Beacon", 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 BeaconHostPlatform does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Job_name(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_name(ctx, field) +func (ec *executionContext) _Beacon_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_lastSeenAt(ctx, field) if err != nil { return graphql.Null } @@ -589,38 +574,35 @@ func (ec *executionContext) _Job_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 + return obj.LastSeenAt, 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_Job_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_lastSeenAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "Beacon", 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) _Job_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_parameters(ctx, field) +func (ec *executionContext) _Beacon_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_tags(ctx, field) if err != nil { return graphql.Null } @@ -633,7 +615,7 @@ func (ec *executionContext) _Job_parameters(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.Parameters, nil + return obj.Tags(ctx) }) if err != nil { ec.Error(ctx, err) @@ -642,26 +624,36 @@ func (ec *executionContext) _Job_parameters(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ent.Tag) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOTag2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTagᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Job_parameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "Beacon", 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_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "kind": + return ec.fieldContext_Tag_kind(ctx, field) + case "beacons": + return ec.fieldContext_Tag_beacons(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } return fc, nil } -func (ec *executionContext) _Job_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_tome(ctx, field) +func (ec *executionContext) _Beacon_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_tasks(ctx, field) if err != nil { return graphql.Null } @@ -674,56 +666,57 @@ func (ec *executionContext) _Job_tome(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.Tome(ctx) + return obj.Tasks(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.Tome) + res := resTmp.([]*ent.Task) fc.Result = res - return ec.marshalNTome2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTome(ctx, field.Selections, res) + return ec.marshalOTask2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTaskᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Job_tome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Beacon_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "Beacon", 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) + return ec.fieldContext_Task_id(ctx, field) case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) + return ec.fieldContext_Task_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 "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) + 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 "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) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _Job_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_bundle(ctx, field) +func (ec *executionContext) _File_id(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_id(ctx, field) if err != nil { return graphql.Null } @@ -736,49 +729,38 @@ func (ec *executionContext) _Job_bundle(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.Bundle(ctx) + 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.File) + res := resTmp.(int) fc.Result = res - return ec.marshalOFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Job_bundle(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_File_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "File", 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_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) - } - return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Job_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_tasks(ctx, field) +func (ec *executionContext) _File_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -791,57 +773,38 @@ func (ec *executionContext) _Job_tasks(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.Tasks(ctx) + 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.([]*ent.Task) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOTask2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTaskᚄ(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Job_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_File_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "File", 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_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 "error": - return ec.fieldContext_Task_error(ctx, field) - case "job": - return ec.fieldContext_Task_job(ctx, field) - case "session": - return ec.fieldContext_Task_session(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Job_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Job) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Job_creator(ctx, field) +func (ec *executionContext) _File_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_lastModifiedAt(ctx, field) if err != nil { return graphql.Null } @@ -854,40 +817,163 @@ func (ec *executionContext) _Job_creator(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.Creator(ctx) + 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.(*ent.User) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOUser2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Job_creator(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_File_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Job", + Object: "File", 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_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) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _File_name(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_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_File_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "File", + 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) _File_size(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_size(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.Size, 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.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_File_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "File", + 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 fc, nil +} + +func (ec *executionContext) _File_hash(ctx context.Context, field graphql.CollectedField, obj *ent.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_hash(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.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) +} + +func (ec *executionContext) fieldContext_File_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "File", + 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 @@ -1239,8 +1325,8 @@ func (ec *executionContext) fieldContext_Query_files(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Query_jobs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_jobs(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 } @@ -1253,7 +1339,7 @@ func (ec *executionContext) _Query_jobs(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().Jobs(rctx, fc.Args["where"].(*ent.JobWhereInput)) + return ec.resolvers.Query().Quests(rctx, fc.Args["where"].(*ent.QuestWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -1265,12 +1351,12 @@ func (ec *executionContext) _Query_jobs(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.([]*ent.Job) + res := resTmp.([]*ent.Quest) fc.Result = res - return ec.marshalNJob2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobᚄ(ctx, field.Selections, res) + return ec.marshalNQuest2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_jobs(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: "Query", Field: field, @@ -1279,25 +1365,25 @@ func (ec *executionContext) fieldContext_Query_jobs(ctx context.Context, field g Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Job_id(ctx, field) + return ec.fieldContext_Quest_id(ctx, field) case "createdAt": - return ec.fieldContext_Job_createdAt(ctx, field) + return ec.fieldContext_Quest_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Job_lastModifiedAt(ctx, field) + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) case "name": - return ec.fieldContext_Job_name(ctx, field) + return ec.fieldContext_Quest_name(ctx, field) case "parameters": - return ec.fieldContext_Job_parameters(ctx, field) + return ec.fieldContext_Quest_parameters(ctx, field) case "tome": - return ec.fieldContext_Job_tome(ctx, field) + return ec.fieldContext_Quest_tome(ctx, field) case "bundle": - return ec.fieldContext_Job_bundle(ctx, field) + return ec.fieldContext_Quest_bundle(ctx, field) case "tasks": - return ec.fieldContext_Job_tasks(ctx, field) + return ec.fieldContext_Quest_tasks(ctx, field) case "creator": - return ec.fieldContext_Job_creator(ctx, field) + return ec.fieldContext_Quest_creator(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Job", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } defer func() { @@ -1307,15 +1393,15 @@ func (ec *executionContext) fieldContext_Query_jobs(ctx context.Context, field g } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_jobs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } -func (ec *executionContext) _Query_sessions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_sessions(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 } @@ -1328,7 +1414,7 @@ func (ec *executionContext) _Query_sessions(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.resolvers.Query().Sessions(rctx, fc.Args["where"].(*ent.SessionWhereInput)) + return ec.resolvers.Query().Beacons(rctx, fc.Args["where"].(*ent.BeaconWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -1340,12 +1426,12 @@ func (ec *executionContext) _Query_sessions(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]*ent.Session) + res := resTmp.([]*ent.Beacon) fc.Result = res - return ec.marshalNSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionᚄ(ctx, field.Selections, res) + return ec.marshalNBeacon2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_sessions(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: "Query", Field: field, @@ -1354,31 +1440,31 @@ func (ec *executionContext) fieldContext_Query_sessions(ctx context.Context, fie Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Session_id(ctx, field) + return ec.fieldContext_Beacon_id(ctx, field) case "name": - return ec.fieldContext_Session_name(ctx, field) + return ec.fieldContext_Beacon_name(ctx, field) case "principal": - return ec.fieldContext_Session_principal(ctx, field) + return ec.fieldContext_Beacon_principal(ctx, field) case "hostname": - return ec.fieldContext_Session_hostname(ctx, field) + return ec.fieldContext_Beacon_hostname(ctx, field) case "identifier": - return ec.fieldContext_Session_identifier(ctx, field) + return ec.fieldContext_Beacon_identifier(ctx, field) case "agentIdentifier": - return ec.fieldContext_Session_agentIdentifier(ctx, field) + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) case "hostIdentifier": - return ec.fieldContext_Session_hostIdentifier(ctx, field) + return ec.fieldContext_Beacon_hostIdentifier(ctx, field) case "hostPrimaryIP": - return ec.fieldContext_Session_hostPrimaryIP(ctx, field) + return ec.fieldContext_Beacon_hostPrimaryIP(ctx, field) case "hostPlatform": - return ec.fieldContext_Session_hostPlatform(ctx, field) + return ec.fieldContext_Beacon_hostPlatform(ctx, field) case "lastSeenAt": - return ec.fieldContext_Session_lastSeenAt(ctx, field) + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) case "tags": - return ec.fieldContext_Session_tags(ctx, field) + return ec.fieldContext_Beacon_tags(ctx, field) case "tasks": - return ec.fieldContext_Session_tasks(ctx, field) + return ec.fieldContext_Beacon_tasks(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Session", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } defer func() { @@ -1388,7 +1474,7 @@ func (ec *executionContext) fieldContext_Query_sessions(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_sessions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } @@ -1440,8 +1526,8 @@ func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field g return ec.fieldContext_Tag_name(ctx, field) case "kind": return ec.fieldContext_Tag_kind(ctx, field) - case "sessions": - return ec.fieldContext_Tag_sessions(ctx, field) + case "beacons": + return ec.fieldContext_Tag_beacons(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, @@ -1729,8 +1815,8 @@ func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, fie return fc, nil } -func (ec *executionContext) _Session_id(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_id(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 } @@ -1760,9 +1846,9 @@ func (ec *executionContext) _Session_id(ctx context.Context, field graphql.Colle return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Session_id(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: "Session", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, @@ -1773,8 +1859,8 @@ func (ec *executionContext) fieldContext_Session_id(ctx context.Context, field g return fc, nil } -func (ec *executionContext) _Session_name(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_name(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 } @@ -1787,7 +1873,7 @@ func (ec *executionContext) _Session_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.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -1799,26 +1885,26 @@ func (ec *executionContext) _Session_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Session_name(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: "Session", + 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) _Session_principal(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_principal(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 } @@ -1831,35 +1917,38 @@ func (ec *executionContext) _Session_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.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_Session_principal(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: "Session", + 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) _Session_hostname(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_hostname(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 } @@ -1872,23 +1961,26 @@ func (ec *executionContext) _Session_hostname(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.Hostname, 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.(string) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Session_hostname(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: "Session", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, @@ -1899,8 +1991,8 @@ func (ec *executionContext) fieldContext_Session_hostname(ctx context.Context, f return fc, nil } -func (ec *executionContext) _Session_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_identifier(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 } @@ -1913,26 +2005,23 @@ func (ec *executionContext) _Session_identifier(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.Identifier, nil + return obj.Parameters, 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_Session_identifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_parameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Session", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, @@ -1943,8 +2032,8 @@ func (ec *executionContext) fieldContext_Session_identifier(ctx context.Context, return fc, nil } -func (ec *executionContext) _Session_agentIdentifier(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_agentIdentifier(ctx, field) +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 } @@ -1957,35 +2046,56 @@ func (ec *executionContext) _Session_agentIdentifier(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.AgentIdentifier, nil + 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") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.Tome) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNTome2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTome(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Session_agentIdentifier(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: "Session", + Object: "Quest", 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_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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, } return fc, nil } -func (ec *executionContext) _Session_hostIdentifier(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_hostIdentifier(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 } @@ -1998,7 +2108,7 @@ func (ec *executionContext) _Session_hostIdentifier(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.HostIdentifier, nil + return obj.Bundle(ctx) }) if err != nil { ec.Error(ctx, err) @@ -2007,26 +2117,40 @@ func (ec *executionContext) _Session_hostIdentifier(ctx context.Context, field g if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.File) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Session_hostIdentifier(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: "Session", + Object: "Quest", 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_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) + } + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) }, } return fc, nil } -func (ec *executionContext) _Session_hostPrimaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_hostPrimaryIP(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 } @@ -2039,7 +2163,7 @@ func (ec *executionContext) _Session_hostPrimaryIP(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HostPrimaryIP, nil + return obj.Tasks(ctx) }) if err != nil { ec.Error(ctx, err) @@ -2048,26 +2172,48 @@ func (ec *executionContext) _Session_hostPrimaryIP(ctx context.Context, field gr if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ent.Task) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOTask2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTaskᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Session_hostPrimaryIP(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: "Session", + Object: "Quest", 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_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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _Session_hostPlatform(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_hostPlatform(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 } @@ -2080,186 +2226,40 @@ func (ec *executionContext) _Session_hostPlatform(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.HostPlatform, 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.(session.HostPlatform) - fc.Result = res - return ec.marshalNSessionHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Session_hostPlatform(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Session", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type SessionHostPlatform does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Session_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_lastSeenAt(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.LastSeenAt, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(time.Time) - fc.Result = res - return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Session_lastSeenAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Session", - 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) _Session_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_tags(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.Tags(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.Tag) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalOTag2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTagᚄ(ctx, field.Selections, res) + return ec.marshalOUser2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Session_tags(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: "Session", + 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_Tag_id(ctx, field) + return ec.fieldContext_User_id(ctx, field) case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "kind": - return ec.fieldContext_Tag_kind(ctx, field) - case "sessions": - return ec.fieldContext_Tag_sessions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Session_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Session) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Session_tasks(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.Tasks(ctx) - }) - 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ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTaskᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Session_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Session", - 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_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 "error": - return ec.fieldContext_Task_error(ctx, field) - case "job": - return ec.fieldContext_Task_job(ctx, field) - case "session": - return ec.fieldContext_Task_session(ctx, field) + 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) } - 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 User", field.Name) }, } return fc, nil @@ -2397,8 +2397,8 @@ func (ec *executionContext) fieldContext_Tag_kind(ctx context.Context, field gra return fc, nil } -func (ec *executionContext) _Tag_sessions(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_sessions(ctx, field) +func (ec *executionContext) _Tag_beacons(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_beacons(ctx, field) if err != nil { return graphql.Null } @@ -2411,7 +2411,7 @@ func (ec *executionContext) _Tag_sessions(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.Sessions(ctx) + return obj.Beacons(ctx) }) if err != nil { ec.Error(ctx, err) @@ -2420,12 +2420,12 @@ func (ec *executionContext) _Tag_sessions(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.Session) + res := resTmp.([]*ent.Beacon) fc.Result = res - return ec.marshalOSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionᚄ(ctx, field.Selections, res) + return ec.marshalOBeacon2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_sessions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Tag", Field: field, @@ -2434,31 +2434,31 @@ func (ec *executionContext) fieldContext_Tag_sessions(ctx context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Session_id(ctx, field) + return ec.fieldContext_Beacon_id(ctx, field) case "name": - return ec.fieldContext_Session_name(ctx, field) + return ec.fieldContext_Beacon_name(ctx, field) case "principal": - return ec.fieldContext_Session_principal(ctx, field) + return ec.fieldContext_Beacon_principal(ctx, field) case "hostname": - return ec.fieldContext_Session_hostname(ctx, field) + return ec.fieldContext_Beacon_hostname(ctx, field) case "identifier": - return ec.fieldContext_Session_identifier(ctx, field) + return ec.fieldContext_Beacon_identifier(ctx, field) case "agentIdentifier": - return ec.fieldContext_Session_agentIdentifier(ctx, field) + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) case "hostIdentifier": - return ec.fieldContext_Session_hostIdentifier(ctx, field) + return ec.fieldContext_Beacon_hostIdentifier(ctx, field) case "hostPrimaryIP": - return ec.fieldContext_Session_hostPrimaryIP(ctx, field) + return ec.fieldContext_Beacon_hostPrimaryIP(ctx, field) case "hostPlatform": - return ec.fieldContext_Session_hostPlatform(ctx, field) + return ec.fieldContext_Beacon_hostPlatform(ctx, field) case "lastSeenAt": - return ec.fieldContext_Session_lastSeenAt(ctx, field) + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) case "tags": - return ec.fieldContext_Session_tags(ctx, field) + return ec.fieldContext_Beacon_tags(ctx, field) case "tasks": - return ec.fieldContext_Session_tasks(ctx, field) + return ec.fieldContext_Beacon_tasks(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Session", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } return fc, nil @@ -2801,8 +2801,8 @@ func (ec *executionContext) fieldContext_Task_error(ctx context.Context, field g return fc, nil } -func (ec *executionContext) _Task_job(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_job(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 } @@ -2815,7 +2815,7 @@ func (ec *executionContext) _Task_job(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.Job(ctx) + return obj.Quest(ctx) }) if err != nil { ec.Error(ctx, err) @@ -2827,12 +2827,12 @@ func (ec *executionContext) _Task_job(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(*ent.Job) + res := resTmp.(*ent.Quest) fc.Result = res - return ec.marshalNJob2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJob(ctx, field.Selections, res) + return ec.marshalNQuest2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuest(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_job(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: "Task", Field: field, @@ -2841,32 +2841,32 @@ func (ec *executionContext) fieldContext_Task_job(ctx context.Context, field gra Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Job_id(ctx, field) + return ec.fieldContext_Quest_id(ctx, field) case "createdAt": - return ec.fieldContext_Job_createdAt(ctx, field) + return ec.fieldContext_Quest_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Job_lastModifiedAt(ctx, field) + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) case "name": - return ec.fieldContext_Job_name(ctx, field) + return ec.fieldContext_Quest_name(ctx, field) case "parameters": - return ec.fieldContext_Job_parameters(ctx, field) + return ec.fieldContext_Quest_parameters(ctx, field) case "tome": - return ec.fieldContext_Job_tome(ctx, field) + return ec.fieldContext_Quest_tome(ctx, field) case "bundle": - return ec.fieldContext_Job_bundle(ctx, field) + return ec.fieldContext_Quest_bundle(ctx, field) case "tasks": - return ec.fieldContext_Job_tasks(ctx, field) + return ec.fieldContext_Quest_tasks(ctx, field) case "creator": - return ec.fieldContext_Job_creator(ctx, field) + return ec.fieldContext_Quest_creator(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Job", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_session(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_session(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 } @@ -2879,7 +2879,7 @@ func (ec *executionContext) _Task_session(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.Session(ctx) + return obj.Beacon(ctx) }) if err != nil { ec.Error(ctx, err) @@ -2891,12 +2891,12 @@ func (ec *executionContext) _Task_session(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(*ent.Session) + res := resTmp.(*ent.Beacon) fc.Result = res - return ec.marshalNSession2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSession(ctx, field.Selections, res) + return ec.marshalNBeacon2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeacon(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_session(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: "Task", Field: field, @@ -2905,31 +2905,31 @@ func (ec *executionContext) fieldContext_Task_session(ctx context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Session_id(ctx, field) + return ec.fieldContext_Beacon_id(ctx, field) case "name": - return ec.fieldContext_Session_name(ctx, field) + return ec.fieldContext_Beacon_name(ctx, field) case "principal": - return ec.fieldContext_Session_principal(ctx, field) + return ec.fieldContext_Beacon_principal(ctx, field) case "hostname": - return ec.fieldContext_Session_hostname(ctx, field) + return ec.fieldContext_Beacon_hostname(ctx, field) case "identifier": - return ec.fieldContext_Session_identifier(ctx, field) + return ec.fieldContext_Beacon_identifier(ctx, field) case "agentIdentifier": - return ec.fieldContext_Session_agentIdentifier(ctx, field) + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) case "hostIdentifier": - return ec.fieldContext_Session_hostIdentifier(ctx, field) + return ec.fieldContext_Beacon_hostIdentifier(ctx, field) case "hostPrimaryIP": - return ec.fieldContext_Session_hostPrimaryIP(ctx, field) + return ec.fieldContext_Beacon_hostPrimaryIP(ctx, field) case "hostPlatform": - return ec.fieldContext_Session_hostPlatform(ctx, field) + return ec.fieldContext_Beacon_hostPlatform(ctx, field) case "lastSeenAt": - return ec.fieldContext_Session_lastSeenAt(ctx, field) + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) case "tags": - return ec.fieldContext_Session_tags(ctx, field) + return ec.fieldContext_Beacon_tags(ctx, field) case "tasks": - return ec.fieldContext_Session_tasks(ctx, field) + return ec.fieldContext_Beacon_tasks(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Session", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } return fc, nil @@ -3519,41 +3519,37 @@ func (ec *executionContext) fieldContext_User_isAdmin(ctx context.Context, field // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputCreateJobInput(ctx context.Context, obj interface{}) (ent.CreateJobInput, error) { - var it ent.CreateJobInput +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 } - fieldsInOrder := [...]string{"name", "parameters", "tomeID"} + 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 "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "parameters": + case "direction": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) - it.Parameters, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + it.Direction, err = ec.unmarshalNOrderDirection2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐOrderDirection(ctx, v) if err != nil { return it, err } - case "tomeID": + case "field": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeID")) - it.TomeID, err = ec.unmarshalNID2int(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + it.Field, err = ec.unmarshalNBeaconOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconOrderField(ctx, v) if err != nil { return it, err } @@ -3563,1213 +3559,1205 @@ func (ec *executionContext) unmarshalInputCreateJobInput(ctx context.Context, ob return it, nil } -func (ec *executionContext) unmarshalInputCreateTagInput(ctx context.Context, obj interface{}) (ent.CreateTagInput, error) { - var it ent.CreateTagInput +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{"name", "kind", "sessionIDs"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "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", "hostname", "hostnameNEQ", "hostnameIn", "hostnameNotIn", "hostnameGT", "hostnameGTE", "hostnameLT", "hostnameLTE", "hostnameContains", "hostnameHasPrefix", "hostnameHasSuffix", "hostnameIsNil", "hostnameNotNil", "hostnameEqualFold", "hostnameContainsFold", "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", "hostIdentifier", "hostIdentifierNEQ", "hostIdentifierIn", "hostIdentifierNotIn", "hostIdentifierGT", "hostIdentifierGTE", "hostIdentifierLT", "hostIdentifierLTE", "hostIdentifierContains", "hostIdentifierHasPrefix", "hostIdentifierHasSuffix", "hostIdentifierIsNil", "hostIdentifierNotNil", "hostIdentifierEqualFold", "hostIdentifierContainsFold", "hostPrimaryIP", "hostPrimaryIPNEQ", "hostPrimaryIPIn", "hostPrimaryIPNotIn", "hostPrimaryIPGT", "hostPrimaryIPGTE", "hostPrimaryIPLT", "hostPrimaryIPLTE", "hostPrimaryIPContains", "hostPrimaryIPHasPrefix", "hostPrimaryIPHasSuffix", "hostPrimaryIPIsNil", "hostPrimaryIPNotNil", "hostPrimaryIPEqualFold", "hostPrimaryIPContainsFold", "hostPlatform", "hostPlatformNEQ", "hostPlatformIn", "hostPlatformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "hasTasks", "hasTasksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "name": + case "not": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + it.Not, err = ec.unmarshalOBeaconWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInput(ctx, v) if err != nil { return it, err } - case "kind": + case "and": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) - it.Kind, err = ec.unmarshalNTagKind2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋtagᚐKind(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + it.And, err = ec.unmarshalOBeaconWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "sessionIDs": + case "or": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sessionIDs")) - it.SessionIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + it.Or, err = ec.unmarshalOBeaconWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } - } - } + case "id": + var err error - return it, nil -} + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + case "idNEQ": + var err error -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 - } + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + case "idIn": + var err error - fieldsInOrder := [...]string{"name", "description", "paramDefs", "eldritch", "fileIDs"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + case "idNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "description": + case "idGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - it.Description, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "paramDefs": + case "idGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefs")) - it.ParamDefs, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "eldritch": + case "idLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritch")) - it.Eldritch, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "fileIDs": + case "idLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileIDs")) - it.FileIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - } - } + case "name": + var err error - 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" - } + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nameNEQ": + 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("nameNEQ")) + it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nameIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐOrderDirection(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "field": + case "nameNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNFileOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileOrderField(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - } - } + case "nameGT": + var err error - return it, nil -} + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nameGTE": + var err error -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 - } + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nameLT": + 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", "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"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nameLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "and": + case "nameContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "or": + case "nameHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "id": + case "nameHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idNEQ": + case "nameEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idIn": + case "nameContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idNotIn": + case "principal": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + it.Principal, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idGT": + case "principalNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + it.PrincipalNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idGTE": + case "principalIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + it.PrincipalIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "idLT": + case "principalNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + it.PrincipalNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "idLTE": + case "principalGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + it.PrincipalGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAt": + case "principalGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + it.PrincipalGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtNEQ": + case "principalLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + it.PrincipalLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtIn": + case "principalLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + it.PrincipalLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtNotIn": + case "principalContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + it.PrincipalContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtGT": + case "principalHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + it.PrincipalHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtGTE": + case "principalHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + it.PrincipalHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtLT": + case "principalIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) + it.PrincipalIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "createdAtLTE": + case "principalNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) + it.PrincipalNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "lastModifiedAt": + case "principalEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - it.LastModifiedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + it.PrincipalEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtNEQ": + case "principalContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - it.LastModifiedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + it.PrincipalContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtIn": + case "hostname": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - it.LastModifiedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostname")) + it.Hostname, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtNotIn": + case "hostnameNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - it.LastModifiedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameNEQ")) + it.HostnameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtGT": + case "hostnameIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - it.LastModifiedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameIn")) + it.HostnameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "lastModifiedAtGTE": + case "hostnameNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - it.LastModifiedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameNotIn")) + it.HostnameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "lastModifiedAtLT": + case "hostnameGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - it.LastModifiedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameGT")) + it.HostnameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtLTE": + case "hostnameGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - it.LastModifiedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameGTE")) + it.HostnameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "name": + case "hostnameLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameLT")) + it.HostnameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameNEQ": + case "hostnameLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameLTE")) + it.HostnameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameIn": + case "hostnameContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameContains")) + it.HostnameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameNotIn": + case "hostnameHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameHasPrefix")) + it.HostnameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameGT": + case "hostnameHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameHasSuffix")) + it.HostnameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameGTE": + case "hostnameIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameIsNil")) + it.HostnameIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "nameLT": + case "hostnameNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameNotNil")) + it.HostnameNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "nameLTE": + case "hostnameEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameEqualFold")) + it.HostnameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameContains": + case "hostnameContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameContainsFold")) + it.HostnameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameHasPrefix": + case "identifier": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + it.Identifier, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameHasSuffix": + case "identifierNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + it.IdentifierNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameEqualFold": + case "identifierIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + it.IdentifierIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "nameContainsFold": + case "identifierNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + it.IdentifierNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "size": + case "identifierGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) - it.Size, err = ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + it.IdentifierGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "sizeNEQ": + case "identifierGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) - it.SizeNEQ, err = ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + it.IdentifierGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "sizeIn": + case "identifierLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) - it.SizeIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + it.IdentifierLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "sizeNotIn": + case "identifierLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) - it.SizeNotIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + it.IdentifierLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "sizeGT": + case "identifierContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) - it.SizeGT, err = ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + it.IdentifierContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "sizeGTE": + case "identifierHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) - it.SizeGTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + it.IdentifierHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "sizeLT": + case "identifierHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) - it.SizeLT, err = ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + it.IdentifierHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "sizeLTE": + case "identifierEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) - it.SizeLTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + it.IdentifierEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hash": + case "identifierContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - it.Hash, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + it.IdentifierContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashNEQ": + case "agentIdentifier": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) - it.HashNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) + it.AgentIdentifier, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashIn": + case "agentIdentifierNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) - it.HashIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) + it.AgentIdentifierNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashNotIn": + case "agentIdentifierIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) - it.HashNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) + it.AgentIdentifierIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "hashGT": + case "agentIdentifierNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) - it.HashGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) + it.AgentIdentifierNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "hashGTE": + case "agentIdentifierGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) - it.HashGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) + it.AgentIdentifierGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashLT": + case "agentIdentifierGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) - it.HashLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) + it.AgentIdentifierGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashLTE": + case "agentIdentifierLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) - it.HashLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) + it.AgentIdentifierLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashContains": + case "agentIdentifierLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) - it.HashContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) + it.AgentIdentifierLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashHasPrefix": + case "agentIdentifierContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) - it.HashHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) + it.AgentIdentifierContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashHasSuffix": + case "agentIdentifierHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) - it.HashHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) + it.AgentIdentifierHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashEqualFold": + case "agentIdentifierHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) - it.HashEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) + it.AgentIdentifierHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hashContainsFold": + case "agentIdentifierIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) - it.HashContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) + it.AgentIdentifierIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputJobOrder(ctx context.Context, obj interface{}) (ent.JobOrder, error) { - var it ent.JobOrder - 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": + case "agentIdentifierNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐOrderDirection(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) + it.AgentIdentifierNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "field": + case "agentIdentifierEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNJobOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobOrderField(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) + it.AgentIdentifierEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputJobWhereInput(ctx context.Context, obj interface{}) (ent.JobWhereInput, error) { - var it ent.JobWhereInput - 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", "parameters", "parametersNEQ", "parametersIn", "parametersNotIn", "parametersGT", "parametersGTE", "parametersLT", "parametersLTE", "parametersContains", "parametersHasPrefix", "parametersHasSuffix", "parametersIsNil", "parametersNotNil", "parametersEqualFold", "parametersContainsFold", "hasTome", "hasTomeWith", "hasBundle", "hasBundleWith", "hasTasks", "hasTasksWith", "hasCreator", "hasCreatorWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": + case "agentIdentifierContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOJobWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInput(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) + it.AgentIdentifierContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "and": + case "hostIdentifier": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOJobWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifier")) + it.HostIdentifier, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "or": + case "hostIdentifierNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOJobWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierNEQ")) + it.HostIdentifierNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "id": + case "hostIdentifierIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierIn")) + it.HostIdentifierIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "idNEQ": + case "hostIdentifierNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierNotIn")) + it.HostIdentifierNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "idIn": + case "hostIdentifierGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierGT")) + it.HostIdentifierGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idNotIn": + case "hostIdentifierGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierGTE")) + it.HostIdentifierGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idGT": + case "hostIdentifierLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierLT")) + it.HostIdentifierLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idGTE": + case "hostIdentifierLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierLTE")) + it.HostIdentifierLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idLT": + case "hostIdentifierContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierContains")) + it.HostIdentifierContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "idLTE": + case "hostIdentifierHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierHasPrefix")) + it.HostIdentifierHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAt": + case "hostIdentifierHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierHasSuffix")) + it.HostIdentifierHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtNEQ": + case "hostIdentifierIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierIsNil")) + it.HostIdentifierIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "createdAtIn": + case "hostIdentifierNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierNotNil")) + it.HostIdentifierNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "createdAtNotIn": + case "hostIdentifierEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierEqualFold")) + it.HostIdentifierEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtGT": + case "hostIdentifierContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierContainsFold")) + it.HostIdentifierContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtGTE": + case "hostPrimaryIP": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIP")) + it.HostPrimaryIP, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtLT": + case "hostPrimaryIPNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPNEQ")) + it.HostPrimaryIPNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAtLTE": + case "hostPrimaryIPIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPIn")) + it.HostPrimaryIPIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "lastModifiedAt": + case "hostPrimaryIPNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - it.LastModifiedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPNotIn")) + it.HostPrimaryIPNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "lastModifiedAtNEQ": + case "hostPrimaryIPGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - it.LastModifiedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPGT")) + it.HostPrimaryIPGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtIn": + case "hostPrimaryIPGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - it.LastModifiedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPGTE")) + it.HostPrimaryIPGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtNotIn": + case "hostPrimaryIPLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - it.LastModifiedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPLT")) + it.HostPrimaryIPLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtGT": + case "hostPrimaryIPLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - it.LastModifiedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPLTE")) + it.HostPrimaryIPLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtGTE": + case "hostPrimaryIPContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - it.LastModifiedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPContains")) + it.HostPrimaryIPContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtLT": + case "hostPrimaryIPHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - it.LastModifiedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPHasPrefix")) + it.HostPrimaryIPHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastModifiedAtLTE": + case "hostPrimaryIPHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - it.LastModifiedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPHasSuffix")) + it.HostPrimaryIPHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "name": + case "hostPrimaryIPIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPIsNil")) + it.HostPrimaryIPIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "nameNEQ": + case "hostPrimaryIPNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPNotNil")) + it.HostPrimaryIPNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "nameIn": + case "hostPrimaryIPEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPEqualFold")) + it.HostPrimaryIPEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameNotIn": + case "hostPrimaryIPContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPContainsFold")) + it.HostPrimaryIPContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "nameGT": + case "hostPlatform": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatform")) + it.HostPlatform, err = ec.unmarshalOBeaconHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx, v) if err != nil { return it, err } - case "nameGTE": + case "hostPlatformNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatformNEQ")) + it.HostPlatformNEQ, err = ec.unmarshalOBeaconHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx, v) if err != nil { return it, err } - case "nameLT": + case "hostPlatformIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatformIn")) + it.HostPlatformIn, err = ec.unmarshalOBeaconHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatformᚄ(ctx, v) if err != nil { return it, err } - case "nameLTE": + case "hostPlatformNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatformNotIn")) + it.HostPlatformNotIn, err = ec.unmarshalOBeaconHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatformᚄ(ctx, v) if err != nil { return it, err } - case "nameContains": + case "lastSeenAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + it.LastSeenAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "nameHasPrefix": + case "lastSeenAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + it.LastSeenAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "nameHasSuffix": + case "lastSeenAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + it.LastSeenAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "nameEqualFold": + case "lastSeenAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + it.LastSeenAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "nameContainsFold": + case "lastSeenAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + it.LastSeenAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "parameters": + case "lastSeenAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) - it.Parameters, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + it.LastSeenAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "parametersNEQ": + case "lastSeenAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNEQ")) - it.ParametersNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + it.LastSeenAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "parametersIn": + case "lastSeenAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIn")) - it.ParametersIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + it.LastSeenAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "parametersNotIn": + case "lastSeenAtIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotIn")) - it.ParametersNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + it.LastSeenAtIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "parametersGT": + case "lastSeenAtNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGT")) - it.ParametersGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + it.LastSeenAtNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "parametersGTE": + case "hasTags": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGTE")) - it.ParametersGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTags")) + it.HasTags, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "parametersLT": + case "hasTagsWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLT")) - it.ParametersLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTagsWith")) + it.HasTagsWith, err = ec.unmarshalOTagWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTagWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "parametersLTE": + case "hasTasks": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLTE")) - it.ParametersLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) + it.HasTasks, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "parametersContains": + case "hasTasksWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContains")) - it.ParametersContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) + it.HasTasksWith, err = ec.unmarshalOTaskWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "parametersHasPrefix": + } + } + + 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("parametersHasPrefix")) - it.ParametersHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "parametersHasSuffix": + case "parameters": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasSuffix")) - it.ParametersHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + it.Parameters, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "parametersIsNil": + case "tomeID": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIsNil")) - it.ParametersIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeID")) + it.TomeID, err = ec.unmarshalNID2int(ctx, v) if err != nil { return it, err } - case "parametersNotNil": + } + } + + 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", "beaconIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotNil")) - it.ParametersNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "parametersEqualFold": + case "kind": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersEqualFold")) - it.ParametersEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) + it.Kind, err = ec.unmarshalNTagKind2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋtagᚐKind(ctx, v) if err != nil { return it, err } - case "parametersContainsFold": + case "beaconIDs": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContainsFold")) - it.ParametersContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("beaconIDs")) + it.BeaconIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "hasTome": - var err error + } + } - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTome")) - it.HasTome, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - case "hasTomeWith": - var err error + return it, nil +} - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomeWith")) - it.HasTomeWith, err = ec.unmarshalOTomeWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTomeWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - case "hasBundle": - var err error +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 + } - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundle")) - it.HasBundle, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - case "hasBundleWith": + fieldsInOrder := [...]string{"name", "description", "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("hasBundleWith")) - it.HasBundleWith, err = ec.unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "hasTasks": + case "description": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - it.HasTasks, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + it.Description, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "hasTasksWith": + case "paramDefs": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - it.HasTasksWith, err = ec.unmarshalOTaskWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTaskWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefs")) + it.ParamDefs, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hasCreator": + case "eldritch": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) - it.HasCreator, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritch")) + it.Eldritch, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "hasCreatorWith": + case "fileIDs": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) - it.HasCreatorWith, err = ec.unmarshalOUserWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUserWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileIDs")) + it.FileIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } @@ -4779,8 +4767,8 @@ func (ec *executionContext) unmarshalInputJobWhereInput(ctx context.Context, obj return it, nil } -func (ec *executionContext) unmarshalInputSessionOrder(ctx context.Context, obj interface{}) (ent.SessionOrder, error) { - var it ent.SessionOrder +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 @@ -4809,7 +4797,7 @@ func (ec *executionContext) unmarshalInputSessionOrder(ctx context.Context, obj var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNSessionOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionOrderField(ctx, v) + it.Field, err = ec.unmarshalNFileOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileOrderField(ctx, v) if err != nil { return it, err } @@ -4819,14 +4807,14 @@ func (ec *executionContext) unmarshalInputSessionOrder(ctx context.Context, obj return it, nil } -func (ec *executionContext) unmarshalInputSessionWhereInput(ctx context.Context, obj interface{}) (ent.SessionWhereInput, error) { - var it ent.SessionWhereInput +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", "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", "hostname", "hostnameNEQ", "hostnameIn", "hostnameNotIn", "hostnameGT", "hostnameGTE", "hostnameLT", "hostnameLTE", "hostnameContains", "hostnameHasPrefix", "hostnameHasSuffix", "hostnameIsNil", "hostnameNotNil", "hostnameEqualFold", "hostnameContainsFold", "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", "hostIdentifier", "hostIdentifierNEQ", "hostIdentifierIn", "hostIdentifierNotIn", "hostIdentifierGT", "hostIdentifierGTE", "hostIdentifierLT", "hostIdentifierLTE", "hostIdentifierContains", "hostIdentifierHasPrefix", "hostIdentifierHasSuffix", "hostIdentifierIsNil", "hostIdentifierNotNil", "hostIdentifierEqualFold", "hostIdentifierContainsFold", "hostPrimaryIP", "hostPrimaryIPNEQ", "hostPrimaryIPIn", "hostPrimaryIPNotIn", "hostPrimaryIPGT", "hostPrimaryIPGTE", "hostPrimaryIPLT", "hostPrimaryIPLTE", "hostPrimaryIPContains", "hostPrimaryIPHasPrefix", "hostPrimaryIPHasSuffix", "hostPrimaryIPIsNil", "hostPrimaryIPNotNil", "hostPrimaryIPEqualFold", "hostPrimaryIPContainsFold", "hostPlatform", "hostPlatformNEQ", "hostPlatformIn", "hostPlatformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "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", "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"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -4837,7 +4825,7 @@ func (ec *executionContext) unmarshalInputSessionWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOSessionWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInput(ctx, v) + it.Not, err = ec.unmarshalOFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx, v) if err != nil { return it, err } @@ -4845,7 +4833,7 @@ func (ec *executionContext) unmarshalInputSessionWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOSessionWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInputᚄ(ctx, v) + it.And, err = ec.unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -4853,7 +4841,7 @@ func (ec *executionContext) unmarshalInputSessionWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOSessionWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInputᚄ(ctx, v) + it.Or, err = ec.unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -4921,939 +4909,935 @@ func (ec *executionContext) unmarshalInputSessionWhereInput(ctx context.Context, if err != nil { return it, err } - case "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "nameNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "nameIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - case "nameNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - case "nameGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "nameGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "nameLT": + case "createdAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "nameLTE": + case "createdAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "nameContains": + case "createdAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "nameHasPrefix": + case "createdAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "nameHasSuffix": + case "createdAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "nameEqualFold": + case "createdAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "nameContainsFold": + case "createdAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principal": + case "createdAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) - it.Principal, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principalNEQ": + case "lastModifiedAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) - it.PrincipalNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + it.LastModifiedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principalIn": + case "lastModifiedAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - it.PrincipalIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + it.LastModifiedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principalNotIn": + case "lastModifiedAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - it.PrincipalNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + it.LastModifiedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "principalGT": + case "lastModifiedAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) - it.PrincipalGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + it.LastModifiedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "principalGTE": + case "lastModifiedAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) - it.PrincipalGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + it.LastModifiedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principalLT": + case "lastModifiedAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) - it.PrincipalLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + it.LastModifiedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principalLTE": + case "lastModifiedAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) - it.PrincipalLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + it.LastModifiedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principalContains": + case "lastModifiedAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - it.PrincipalContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + it.LastModifiedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "principalHasPrefix": + case "name": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - it.PrincipalHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "principalHasSuffix": + case "nameNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) - it.PrincipalHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "principalIsNil": + case "nameIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) - it.PrincipalIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "principalNotNil": + case "nameNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) - it.PrincipalNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "principalEqualFold": + case "nameGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) - it.PrincipalEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "principalContainsFold": + case "nameGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) - it.PrincipalContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostname": + case "nameLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostname")) - it.Hostname, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostnameNEQ": + case "nameLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameNEQ")) - it.HostnameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostnameIn": + case "nameContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameIn")) - it.HostnameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostnameNotIn": + case "nameHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameNotIn")) - it.HostnameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostnameGT": + case "nameHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameGT")) - it.HostnameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostnameGTE": + case "nameEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameGTE")) - it.HostnameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostnameLT": + case "nameContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameLT")) - it.HostnameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostnameLTE": + case "size": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameLTE")) - it.HostnameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + it.Size, err = ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - case "hostnameContains": + case "sizeNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameContains")) - it.HostnameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + it.SizeNEQ, err = ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - case "hostnameHasPrefix": + case "sizeIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameHasPrefix")) - it.HostnameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + it.SizeIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "hostnameHasSuffix": + case "sizeNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameHasSuffix")) - it.HostnameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + it.SizeNotIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "hostnameIsNil": + case "sizeGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameIsNil")) - it.HostnameIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + it.SizeGT, err = ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - case "hostnameNotNil": + case "sizeGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameNotNil")) - it.HostnameNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + it.SizeGTE, err = ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - case "hostnameEqualFold": + case "sizeLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameEqualFold")) - it.HostnameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + it.SizeLT, err = ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - case "hostnameContainsFold": + case "sizeLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostnameContainsFold")) - it.HostnameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + it.SizeLTE, err = ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - case "identifier": + case "hash": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) - it.Identifier, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + it.Hash, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierNEQ": + case "hashNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) - it.IdentifierNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + it.HashNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierIn": + case "hashIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) - it.IdentifierIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + it.HashIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "identifierNotIn": + case "hashNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) - it.IdentifierNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + it.HashNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "identifierGT": + case "hashGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) - it.IdentifierGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + it.HashGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierGTE": + case "hashGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) - it.IdentifierGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + it.HashGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierLT": + case "hashLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) - it.IdentifierLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + it.HashLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierLTE": + case "hashLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) - it.IdentifierLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + it.HashLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierContains": + case "hashContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) - it.IdentifierContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + it.HashContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierHasPrefix": + case "hashHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - it.IdentifierHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + it.HashHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierHasSuffix": + case "hashHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) - it.IdentifierHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + it.HashHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierEqualFold": + case "hashEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) - it.IdentifierEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + it.HashEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "identifierContainsFold": + case "hashContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) - it.IdentifierContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + it.HashContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "agentIdentifier": + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj interface{}) (ent.QuestOrder, error) { + var it ent.QuestOrder + 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("agentIdentifier")) - it.AgentIdentifier, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + it.Direction, err = ec.unmarshalNOrderDirection2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐOrderDirection(ctx, v) if err != nil { return it, err } - case "agentIdentifierNEQ": + case "field": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) - it.AgentIdentifierNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + it.Field, err = ec.unmarshalNQuestOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestOrderField(ctx, v) if err != nil { return it, err } - case "agentIdentifierIn": + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, obj interface{}) (ent.QuestWhereInput, error) { + var it ent.QuestWhereInput + 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", "parameters", "parametersNEQ", "parametersIn", "parametersNotIn", "parametersGT", "parametersGTE", "parametersLT", "parametersLTE", "parametersContains", "parametersHasPrefix", "parametersHasSuffix", "parametersIsNil", "parametersNotNil", "parametersEqualFold", "parametersContainsFold", "hasTome", "hasTomeWith", "hasBundle", "hasBundleWith", "hasTasks", "hasTasksWith", "hasCreator", "hasCreatorWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) - it.AgentIdentifierIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + it.Not, err = ec.unmarshalOQuestWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInput(ctx, v) if err != nil { return it, err } - case "agentIdentifierNotIn": + case "and": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) - it.AgentIdentifierNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + it.And, err = ec.unmarshalOQuestWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "agentIdentifierGT": + case "or": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) - it.AgentIdentifierGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + it.Or, err = ec.unmarshalOQuestWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "agentIdentifierGTE": + case "id": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) - it.AgentIdentifierGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "agentIdentifierLT": + case "idNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) - it.AgentIdentifierLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "agentIdentifierLTE": + case "idIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) - it.AgentIdentifierLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "agentIdentifierContains": + case "idNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) - it.AgentIdentifierContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "agentIdentifierHasPrefix": + case "idGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) - it.AgentIdentifierHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "agentIdentifierHasSuffix": + case "idGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) - it.AgentIdentifierHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "agentIdentifierIsNil": + case "idLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) - it.AgentIdentifierIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "agentIdentifierNotNil": + case "idLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) - it.AgentIdentifierNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "agentIdentifierEqualFold": + case "createdAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) - it.AgentIdentifierEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "agentIdentifierContainsFold": + case "createdAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) - it.AgentIdentifierContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifier": + case "createdAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifier")) - it.HostIdentifier, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "hostIdentifierNEQ": + case "createdAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierNEQ")) - it.HostIdentifierNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "hostIdentifierIn": + case "createdAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierIn")) - it.HostIdentifierIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierNotIn": + case "createdAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierNotIn")) - it.HostIdentifierNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierGT": + case "createdAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierGT")) - it.HostIdentifierGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierGTE": + case "createdAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierGTE")) - it.HostIdentifierGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierLT": + case "lastModifiedAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierLT")) - it.HostIdentifierLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + it.LastModifiedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierLTE": + case "lastModifiedAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierLTE")) - it.HostIdentifierLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + it.LastModifiedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierContains": + case "lastModifiedAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierContains")) - it.HostIdentifierContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + it.LastModifiedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "hostIdentifierHasPrefix": + case "lastModifiedAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierHasPrefix")) - it.HostIdentifierHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + it.LastModifiedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - case "hostIdentifierHasSuffix": + case "lastModifiedAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierHasSuffix")) - it.HostIdentifierHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + it.LastModifiedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierIsNil": + case "lastModifiedAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierIsNil")) - it.HostIdentifierIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + it.LastModifiedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierNotNil": + case "lastModifiedAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierNotNil")) - it.HostIdentifierNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + it.LastModifiedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierEqualFold": + case "lastModifiedAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierEqualFold")) - it.HostIdentifierEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + it.LastModifiedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - case "hostIdentifierContainsFold": + case "name": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIdentifierContainsFold")) - it.HostIdentifierContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIP": + case "nameNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIP")) - it.HostPrimaryIP, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPNEQ": + case "nameIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPNEQ")) - it.HostPrimaryIPNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPIn": + case "nameNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPIn")) - it.HostPrimaryIPIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPNotIn": + case "nameGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPNotIn")) - it.HostPrimaryIPNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPGT": + case "nameGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPGT")) - it.HostPrimaryIPGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPGTE": + case "nameLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPGTE")) - it.HostPrimaryIPGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPLT": + case "nameLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPLT")) - it.HostPrimaryIPLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPLTE": + case "nameContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPLTE")) - it.HostPrimaryIPLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPContains": + case "nameHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPContains")) - it.HostPrimaryIPContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPHasPrefix": + case "nameHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPHasPrefix")) - it.HostPrimaryIPHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPHasSuffix": + case "nameEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPHasSuffix")) - it.HostPrimaryIPHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPIsNil": + case "nameContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPIsNil")) - it.HostPrimaryIPIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPNotNil": + case "parameters": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPNotNil")) - it.HostPrimaryIPNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + it.Parameters, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPEqualFold": + case "parametersNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPEqualFold")) - it.HostPrimaryIPEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNEQ")) + it.ParametersNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPrimaryIPContainsFold": + case "parametersIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPrimaryIPContainsFold")) - it.HostPrimaryIPContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIn")) + it.ParametersIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "hostPlatform": + case "parametersNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatform")) - it.HostPlatform, err = ec.unmarshalOSessionHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotIn")) + it.ParametersNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "hostPlatformNEQ": + case "parametersGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatformNEQ")) - it.HostPlatformNEQ, err = ec.unmarshalOSessionHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGT")) + it.ParametersGT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPlatformIn": + case "parametersGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatformIn")) - it.HostPlatformIn, err = ec.unmarshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatformᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGTE")) + it.ParametersGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hostPlatformNotIn": + case "parametersLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatformNotIn")) - it.HostPlatformNotIn, err = ec.unmarshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatformᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLT")) + it.ParametersLT, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastSeenAt": + case "parametersLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) - it.LastSeenAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLTE")) + it.ParametersLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastSeenAtNEQ": + case "parametersContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) - it.LastSeenAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContains")) + it.ParametersContains, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastSeenAtIn": + case "parametersHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - it.LastSeenAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasPrefix")) + it.ParametersHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastSeenAtNotIn": + case "parametersHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - it.LastSeenAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasSuffix")) + it.ParametersHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastSeenAtGT": + case "parametersIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) - it.LastSeenAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIsNil")) + it.ParametersIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "lastSeenAtGTE": + case "parametersNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) - it.LastSeenAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotNil")) + it.ParametersNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - case "lastSeenAtLT": + case "parametersEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - it.LastSeenAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersEqualFold")) + it.ParametersEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastSeenAtLTE": + case "parametersContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - it.LastSeenAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContainsFold")) + it.ParametersContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "lastSeenAtIsNil": + case "hasTome": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) - it.LastSeenAtIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTome")) + it.HasTome, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "lastSeenAtNotNil": + case "hasTomeWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - it.LastSeenAtNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomeWith")) + it.HasTomeWith, err = ec.unmarshalOTomeWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTomeWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "hasTags": + case "hasBundle": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTags")) - it.HasTags, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundle")) + it.HasBundle, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "hasTagsWith": + case "hasBundleWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTagsWith")) - it.HasTagsWith, err = ec.unmarshalOTagWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐTagWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundleWith")) + it.HasBundleWith, err = ec.unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -5873,6 +5857,22 @@ func (ec *executionContext) unmarshalInputSessionWhereInput(ctx context.Context, if err != nil { return it, err } + case "hasCreator": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) + it.HasCreator, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + case "hasCreatorWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) + it.HasCreatorWith, err = ec.unmarshalOUserWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUserWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } } } @@ -5926,7 +5926,7 @@ func (ec *executionContext) unmarshalInputTagWhereInput(ctx context.Context, obj asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "kind", "kindNEQ", "kindIn", "kindNotIn", "hasSessions", "hasSessionsWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "kind", "kindNEQ", "kindIn", "kindNotIn", "hasBeacons", "hasBeaconsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -6157,19 +6157,19 @@ func (ec *executionContext) unmarshalInputTagWhereInput(ctx context.Context, obj if err != nil { return it, err } - case "hasSessions": + case "hasBeacons": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSessions")) - it.HasSessions, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacons")) + it.HasBeacons, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "hasSessionsWith": + case "hasBeaconsWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSessionsWith")) - it.HasSessionsWith, err = ec.unmarshalOSessionWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconsWith")) + it.HasBeaconsWith, err = ec.unmarshalOBeaconWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -6226,7 +6226,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", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasJob", "hasJobWith", "hasSession", "hasSessionWith"} + 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", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasQuest", "hasQuestWith", "hasBeacon", "hasBeaconWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -6929,35 +6929,35 @@ func (ec *executionContext) unmarshalInputTaskWhereInput(ctx context.Context, ob if err != nil { return it, err } - case "hasJob": + case "hasQuest": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasJob")) - it.HasJob, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasQuest")) + it.HasQuest, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "hasJobWith": + case "hasQuestWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasJobWith")) - it.HasJobWith, err = ec.unmarshalOJobWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasQuestWith")) + it.HasQuestWith, err = ec.unmarshalOQuestWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "hasSession": + case "hasBeacon": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSession")) - it.HasSession, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacon")) + it.HasBeacon, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "hasSessionWith": + case "hasBeaconWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSessionWith")) - it.HasSessionWith, err = ec.unmarshalOSessionWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconWith")) + it.HasBeaconWith, err = ec.unmarshalOBeaconWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -7691,8 +7691,8 @@ func (ec *executionContext) unmarshalInputTomeWhereInput(ctx context.Context, ob return it, nil } -func (ec *executionContext) unmarshalInputUpdateSessionInput(ctx context.Context, obj interface{}) (ent.UpdateSessionInput, error) { - var it ent.UpdateSessionInput +func (ec *executionContext) unmarshalInputUpdateBeaconInput(ctx context.Context, obj interface{}) (ent.UpdateBeaconInput, error) { + var it ent.UpdateBeaconInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v @@ -7766,7 +7766,7 @@ func (ec *executionContext) unmarshalInputUpdateTagInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"name", "kind", "addSessionIDs", "removeSessionIDs", "clearSessions"} + fieldsInOrder := [...]string{"name", "kind", "addBeaconIDs", "removeBeaconIDs", "clearBeacons"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -7789,27 +7789,27 @@ func (ec *executionContext) unmarshalInputUpdateTagInput(ctx context.Context, ob if err != nil { return it, err } - case "addSessionIDs": + case "addBeaconIDs": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addSessionIDs")) - it.AddSessionIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addBeaconIDs")) + it.AddBeaconIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "removeSessionIDs": + case "removeBeaconIDs": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeSessionIDs")) - it.RemoveSessionIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeBeaconIDs")) + it.RemoveBeaconIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - case "clearSessions": + case "clearBeacons": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSessions")) - it.ClearSessions, err = ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearBeacons")) + it.ClearBeacons, err = ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } @@ -8227,21 +8227,21 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj switch obj := (obj).(type) { case nil: return graphql.Null - case *ent.File: + case *ent.Beacon: if obj == nil { return graphql.Null } - return ec._File(ctx, sel, obj) - case *ent.Job: + return ec._Beacon(ctx, sel, obj) + case *ent.File: if obj == nil { return graphql.Null } - return ec._Job(ctx, sel, obj) - case *ent.Session: + return ec._File(ctx, sel, obj) + case *ent.Quest: if obj == nil { return graphql.Null } - return ec._Session(ctx, sel, obj) + return ec._Quest(ctx, sel, obj) case *ent.Tag: if obj == nil { return graphql.Null @@ -8271,112 +8271,69 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj // region **************************** object.gotpl **************************** -var fileImplementors = []string{"File", "Node"} +var beaconImplementors = []string{"Beacon", "Node"} -func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj *ent.File) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, fileImplementors) +func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, obj *ent.Beacon) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, beaconImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("File") + out.Values[i] = graphql.MarshalString("Beacon") case "id": - out.Values[i] = ec._File_id(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "createdAt": - - out.Values[i] = ec._File_createdAt(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "lastModifiedAt": - - out.Values[i] = ec._File_lastModifiedAt(ctx, field, obj) + out.Values[i] = ec._Beacon_id(ctx, field, obj) if out.Values[i] == graphql.Null { - invalids++ + atomic.AddUint32(&invalids, 1) } case "name": - out.Values[i] = ec._File_name(ctx, field, obj) - - if out.Values[i] == graphql.Null { - invalids++ - } - case "size": - - out.Values[i] = ec._File_size(ctx, field, obj) + out.Values[i] = ec._Beacon_name(ctx, field, obj) if out.Values[i] == graphql.Null { - invalids++ + atomic.AddUint32(&invalids, 1) } - case "hash": + case "principal": - out.Values[i] = ec._File_hash(ctx, field, obj) + out.Values[i] = ec._Beacon_principal(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} + case "hostname": -var jobImplementors = []string{"Job", "Node"} + out.Values[i] = ec._Beacon_hostname(ctx, field, obj) -func (ec *executionContext) _Job(ctx context.Context, sel ast.SelectionSet, obj *ent.Job) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, jobImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Job") - case "id": + case "identifier": - out.Values[i] = ec._Job_id(ctx, field, obj) + out.Values[i] = ec._Beacon_identifier(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } - case "createdAt": + case "agentIdentifier": - out.Values[i] = ec._Job_createdAt(ctx, field, obj) + out.Values[i] = ec._Beacon_agentIdentifier(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "lastModifiedAt": + case "hostIdentifier": - out.Values[i] = ec._Job_lastModifiedAt(ctx, field, obj) + out.Values[i] = ec._Beacon_hostIdentifier(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "name": + case "hostPrimaryIP": + + out.Values[i] = ec._Beacon_hostPrimaryIP(ctx, field, obj) + + case "hostPlatform": - out.Values[i] = ec._Job_name(ctx, field, obj) + out.Values[i] = ec._Beacon_hostPlatform(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } - case "parameters": + case "lastSeenAt": - out.Values[i] = ec._Job_parameters(ctx, field, obj) + out.Values[i] = ec._Beacon_lastSeenAt(ctx, field, obj) - case "tome": + case "tags": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8385,10 +8342,7 @@ func (ec *executionContext) _Job(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Job_tome(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } + res = ec._Beacon_tags(ctx, field, obj) return res } @@ -8396,7 +8350,7 @@ func (ec *executionContext) _Job(ctx context.Context, sel ast.SelectionSet, obj return innerFunc(ctx) }) - case "bundle": + case "tasks": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8405,7 +8359,7 @@ func (ec *executionContext) _Job(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Job_bundle(ctx, field, obj) + res = ec._Beacon_tasks(ctx, field, obj) return res } @@ -8413,40 +8367,69 @@ func (ec *executionContext) _Job(ctx context.Context, sel ast.SelectionSet, obj return innerFunc(ctx) }) - case "tasks": - field := field + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Job_tasks(ctx, field, obj) - return res +var fileImplementors = []string{"File", "Node"} + +func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj *ent.File) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, fileImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("File") + case "id": + + out.Values[i] = ec._File_id(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ } + case "createdAt": - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + out.Values[i] = ec._File_createdAt(ctx, field, obj) - }) - case "creator": - field := field + if out.Values[i] == graphql.Null { + invalids++ + } + case "lastModifiedAt": - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Job_creator(ctx, field, obj) - return res + out.Values[i] = ec._File_lastModifiedAt(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ } + case "name": - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + out.Values[i] = ec._File_name(ctx, field, obj) - }) + if out.Values[i] == graphql.Null { + invalids++ + } + case "size": + + out.Values[i] = ec._File_size(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "hash": + + out.Values[i] = ec._File_hash(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -8586,7 +8569,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Concurrently(i, func() graphql.Marshaler { return rrm(innerCtx) }) - case "jobs": + case "quests": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8595,7 +8578,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_jobs(ctx, field) + res = ec._Query_quests(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -8609,7 +8592,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Concurrently(i, func() graphql.Marshaler { return rrm(innerCtx) }) - case "sessions": + case "beacons": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8618,7 +8601,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_sessions(ctx, field) + res = ec._Query_beacons(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -8724,69 +8707,86 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return out } -var sessionImplementors = []string{"Session", "Node"} +var questImplementors = []string{"Quest", "Node"} -func (ec *executionContext) _Session(ctx context.Context, sel ast.SelectionSet, obj *ent.Session) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, sessionImplementors) +func (ec *executionContext) _Quest(ctx context.Context, sel ast.SelectionSet, obj *ent.Quest) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, questImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Session") + out.Values[i] = graphql.MarshalString("Quest") case "id": - out.Values[i] = ec._Session_id(ctx, field, obj) + out.Values[i] = ec._Quest_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } - case "name": + case "createdAt": + + out.Values[i] = ec._Quest_createdAt(ctx, field, obj) + + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + case "lastModifiedAt": - out.Values[i] = ec._Session_name(ctx, field, obj) + out.Values[i] = ec._Quest_lastModifiedAt(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } - case "principal": - - out.Values[i] = ec._Session_principal(ctx, field, obj) - - case "hostname": - - out.Values[i] = ec._Session_hostname(ctx, field, obj) - - case "identifier": + case "name": - out.Values[i] = ec._Session_identifier(ctx, field, obj) + out.Values[i] = ec._Quest_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } - case "agentIdentifier": - - out.Values[i] = ec._Session_agentIdentifier(ctx, field, obj) - - case "hostIdentifier": + case "parameters": - out.Values[i] = ec._Session_hostIdentifier(ctx, field, obj) + out.Values[i] = ec._Quest_parameters(ctx, field, obj) - case "hostPrimaryIP": + case "tome": + field := field - out.Values[i] = ec._Session_hostPrimaryIP(ctx, field, obj) + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Quest_tome(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + } - case "hostPlatform": + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) - out.Values[i] = ec._Session_hostPlatform(ctx, field, obj) + }) + case "bundle": + field := field - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Quest_bundle(ctx, field, obj) + return res } - case "lastSeenAt": - out.Values[i] = ec._Session_lastSeenAt(ctx, field, obj) + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) - case "tags": + }) + case "tasks": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8795,7 +8795,7 @@ func (ec *executionContext) _Session(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Session_tags(ctx, field, obj) + res = ec._Quest_tasks(ctx, field, obj) return res } @@ -8803,7 +8803,7 @@ func (ec *executionContext) _Session(ctx context.Context, sel ast.SelectionSet, return innerFunc(ctx) }) - case "tasks": + case "creator": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8812,7 +8812,7 @@ func (ec *executionContext) _Session(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Session_tasks(ctx, field, obj) + res = ec._Quest_creator(ctx, field, obj) return res } @@ -8862,7 +8862,7 @@ func (ec *executionContext) _Tag(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } - case "sessions": + case "beacons": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8871,7 +8871,7 @@ func (ec *executionContext) _Tag(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Tag_sessions(ctx, field, obj) + res = ec._Tag_beacons(ctx, field, obj) return res } @@ -8941,7 +8941,7 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj out.Values[i] = ec._Task_error(ctx, field, obj) - case "job": + case "quest": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8950,7 +8950,7 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Task_job(ctx, field, obj) + res = ec._Task_quest(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -8961,7 +8961,7 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj return innerFunc(ctx) }) - case "session": + case "beacon": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -8970,7 +8970,7 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Task_session(ctx, field, obj) + res = ec._Task_beacon(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -9136,22 +9136,11 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNCreateJobInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateJobInput(ctx context.Context, v interface{}) (ent.CreateJobInput, error) { - res, err := ec.unmarshalInputCreateJobInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCreateTagInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateTagInput(ctx context.Context, v interface{}) (ent.CreateTagInput, error) { - res, err := ec.unmarshalInputCreateTagInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCreateTomeInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateTomeInput(ctx context.Context, v interface{}) (ent.CreateTomeInput, error) { - res, err := ec.unmarshalInputCreateTomeInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) +func (ec *executionContext) marshalNBeacon2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeacon(ctx context.Context, sel ast.SelectionSet, v ent.Beacon) graphql.Marshaler { + return ec._Beacon(ctx, sel, &v) } -func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.File) graphql.Marshaler { +func (ec *executionContext) marshalNBeacon2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Beacon) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -9175,7 +9164,7 @@ func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealm if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx, sel, v[i]) + ret[i] = ec.marshalNBeacon2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeacon(ctx, sel, v[i]) } if isLen1 { f(i) @@ -9195,23 +9184,33 @@ func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealm return ret } -func (ec *executionContext) marshalNFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx context.Context, sel ast.SelectionSet, v *ent.File) graphql.Marshaler { +func (ec *executionContext) marshalNBeacon2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeacon(ctx context.Context, sel ast.SelectionSet, v *ent.Beacon) 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._File(ctx, sel, v) + return ec._Beacon(ctx, sel, v) } -func (ec *executionContext) unmarshalNFileOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileOrderField(ctx context.Context, v interface{}) (*ent.FileOrderField, error) { - var res = new(ent.FileOrderField) +func (ec *executionContext) unmarshalNBeaconHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx context.Context, v interface{}) (beacon.HostPlatform, error) { + var res beacon.HostPlatform err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNFileOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.FileOrderField) graphql.Marshaler { +func (ec *executionContext) marshalNBeaconHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx context.Context, sel ast.SelectionSet, v beacon.HostPlatform) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNBeaconOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconOrderField(ctx context.Context, v interface{}) (*ent.BeaconOrderField, error) { + var res = new(ent.BeaconOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBeaconOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.BeaconOrderField) 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") @@ -9221,12 +9220,27 @@ func (ec *executionContext) marshalNFileOrderField2ᚖgithubᚗcomᚋkcarretto return v } -func (ec *executionContext) unmarshalNFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx context.Context, v interface{}) (*ent.FileWhereInput, error) { - res, err := ec.unmarshalInputFileWhereInput(ctx, v) +func (ec *executionContext) unmarshalNBeaconWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInput(ctx context.Context, v interface{}) (*ent.BeaconWhereInput, error) { + res, err := ec.unmarshalInputBeaconWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNJob2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Job) graphql.Marshaler { +func (ec *executionContext) unmarshalNCreateQuestInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateQuestInput(ctx context.Context, v interface{}) (ent.CreateQuestInput, error) { + res, err := ec.unmarshalInputCreateQuestInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNCreateTagInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateTagInput(ctx context.Context, v interface{}) (ent.CreateTagInput, error) { + res, err := ec.unmarshalInputCreateTagInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNCreateTomeInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateTomeInput(ctx context.Context, v interface{}) (ent.CreateTomeInput, error) { + res, err := ec.unmarshalInputCreateTomeInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.File) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -9250,7 +9264,7 @@ func (ec *executionContext) marshalNJob2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealm if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNJob2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJob(ctx, sel, v[i]) + ret[i] = ec.marshalNFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx, sel, v[i]) } if isLen1 { f(i) @@ -9270,23 +9284,23 @@ func (ec *executionContext) marshalNJob2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealm return ret } -func (ec *executionContext) marshalNJob2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJob(ctx context.Context, sel ast.SelectionSet, v *ent.Job) graphql.Marshaler { +func (ec *executionContext) marshalNFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx context.Context, sel ast.SelectionSet, v *ent.File) 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._Job(ctx, sel, v) + return ec._File(ctx, sel, v) } -func (ec *executionContext) unmarshalNJobOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobOrderField(ctx context.Context, v interface{}) (*ent.JobOrderField, error) { - var res = new(ent.JobOrderField) +func (ec *executionContext) unmarshalNFileOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileOrderField(ctx context.Context, v interface{}) (*ent.FileOrderField, error) { + var res = new(ent.FileOrderField) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNJobOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.JobOrderField) graphql.Marshaler { +func (ec *executionContext) marshalNFileOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.FileOrderField) 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") @@ -9296,8 +9310,8 @@ func (ec *executionContext) marshalNJobOrderField2ᚖgithubᚗcomᚋkcarrettoᚋ return v } -func (ec *executionContext) unmarshalNJobWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInput(ctx context.Context, v interface{}) (*ent.JobWhereInput, error) { - res, err := ec.unmarshalInputJobWhereInput(ctx, v) +func (ec *executionContext) unmarshalNFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx context.Context, v interface{}) (*ent.FileWhereInput, error) { + res, err := ec.unmarshalInputFileWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } @@ -9349,11 +9363,7 @@ func (ec *executionContext) marshalNOrderDirection2githubᚗcomᚋkcarrettoᚋre return v } -func (ec *executionContext) marshalNSession2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSession(ctx context.Context, sel ast.SelectionSet, v ent.Session) graphql.Marshaler { - return ec._Session(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Session) graphql.Marshaler { +func (ec *executionContext) marshalNQuest2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Quest) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -9377,7 +9387,7 @@ func (ec *executionContext) marshalNSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrea if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNSession2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSession(ctx, sel, v[i]) + ret[i] = ec.marshalNQuest2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuest(ctx, sel, v[i]) } if isLen1 { f(i) @@ -9397,33 +9407,23 @@ func (ec *executionContext) marshalNSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrea return ret } -func (ec *executionContext) marshalNSession2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSession(ctx context.Context, sel ast.SelectionSet, v *ent.Session) graphql.Marshaler { +func (ec *executionContext) marshalNQuest2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuest(ctx context.Context, sel ast.SelectionSet, v *ent.Quest) 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._Session(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNSessionHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx context.Context, v interface{}) (session.HostPlatform, error) { - var res session.HostPlatform - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNSessionHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx context.Context, sel ast.SelectionSet, v session.HostPlatform) graphql.Marshaler { - return v + return ec._Quest(ctx, sel, v) } -func (ec *executionContext) unmarshalNSessionOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionOrderField(ctx context.Context, v interface{}) (*ent.SessionOrderField, error) { - var res = new(ent.SessionOrderField) +func (ec *executionContext) unmarshalNQuestOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestOrderField(ctx context.Context, v interface{}) (*ent.QuestOrderField, error) { + var res = new(ent.QuestOrderField) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNSessionOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.SessionOrderField) graphql.Marshaler { +func (ec *executionContext) marshalNQuestOrderField2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.QuestOrderField) 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") @@ -9433,8 +9433,8 @@ func (ec *executionContext) marshalNSessionOrderField2ᚖgithubᚗcomᚋkcarrett return v } -func (ec *executionContext) unmarshalNSessionWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInput(ctx context.Context, v interface{}) (*ent.SessionWhereInput, error) { - res, err := ec.unmarshalInputSessionWhereInput(ctx, v) +func (ec *executionContext) unmarshalNQuestWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInput(ctx context.Context, v interface{}) (*ent.QuestWhereInput, error) { + res, err := ec.unmarshalInputQuestWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } @@ -9681,8 +9681,8 @@ func (ec *executionContext) unmarshalNTomeWhereInput2ᚖgithubᚗcomᚋkcarretto return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNUpdateSessionInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUpdateSessionInput(ctx context.Context, v interface{}) (ent.UpdateSessionInput, error) { - res, err := ec.unmarshalInputUpdateSessionInput(ctx, v) +func (ec *executionContext) unmarshalNUpdateBeaconInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUpdateBeaconInput(ctx context.Context, v interface{}) (ent.UpdateBeaconInput, error) { + res, err := ec.unmarshalInputUpdateBeaconInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } @@ -9755,23 +9755,7 @@ func (ec *executionContext) unmarshalNUserWhereInput2ᚖgithubᚗcomᚋkcarretto return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOCursor2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCursor(ctx context.Context, v interface{}) (*ent.Cursor, error) { - if v == nil { - return nil, nil - } - var res = new(ent.Cursor) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOCursor2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCursor(ctx context.Context, sel ast.SelectionSet, v *ent.Cursor) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v -} - -func (ec *executionContext) marshalOFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.File) graphql.Marshaler { +func (ec *executionContext) marshalOBeacon2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Beacon) graphql.Marshaler { if v == nil { return graphql.Null } @@ -9798,7 +9782,7 @@ func (ec *executionContext) marshalOFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealm if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx, sel, v[i]) + ret[i] = ec.marshalNBeacon2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeacon(ctx, sel, v[i]) } if isLen1 { f(i) @@ -9818,49 +9802,7 @@ func (ec *executionContext) marshalOFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealm return ret } -func (ec *executionContext) marshalOFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx context.Context, sel ast.SelectionSet, v *ent.File) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._File(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.FileWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.FileWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx context.Context, v interface{}) (*ent.FileWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputFileWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOJob2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJob(ctx context.Context, sel ast.SelectionSet, v *ent.Job) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Job(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOJobWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.JobWhereInput, error) { +func (ec *executionContext) unmarshalOBeaconHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatformᚄ(ctx context.Context, v interface{}) ([]beacon.HostPlatform, error) { if v == nil { return nil, nil } @@ -9869,10 +9811,10 @@ func (ec *executionContext) unmarshalOJobWhereInput2ᚕᚖgithubᚗcomᚋkcarret vSlice = graphql.CoerceList(v) } var err error - res := make([]*ent.JobWhereInput, len(vSlice)) + res := make([]beacon.HostPlatform, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNJobWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalNBeaconHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx, vSlice[i]) if err != nil { return nil, err } @@ -9880,22 +9822,7 @@ func (ec *executionContext) unmarshalOJobWhereInput2ᚕᚖgithubᚗcomᚋkcarret return res, nil } -func (ec *executionContext) unmarshalOJobWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJobWhereInput(ctx context.Context, v interface{}) (*ent.JobWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputJobWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalONode2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋ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) marshalOSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Session) graphql.Marshaler { +func (ec *executionContext) marshalOBeaconHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatformᚄ(ctx context.Context, sel ast.SelectionSet, v []beacon.HostPlatform) graphql.Marshaler { if v == nil { return graphql.Null } @@ -9922,7 +9849,7 @@ func (ec *executionContext) marshalOSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrea if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNSession2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSession(ctx, sel, v[i]) + ret[i] = ec.marshalNBeaconHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx, sel, v[i]) } if isLen1 { f(i) @@ -9942,7 +9869,23 @@ func (ec *executionContext) marshalOSession2ᚕᚖgithubᚗcomᚋkcarrettoᚋrea return ret } -func (ec *executionContext) unmarshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatformᚄ(ctx context.Context, v interface{}) ([]session.HostPlatform, error) { +func (ec *executionContext) unmarshalOBeaconHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx context.Context, v interface{}) (*beacon.HostPlatform, error) { + if v == nil { + return nil, nil + } + var res = new(beacon.HostPlatform) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBeaconHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx context.Context, sel ast.SelectionSet, v *beacon.HostPlatform) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOBeaconWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.BeaconWhereInput, error) { if v == nil { return nil, nil } @@ -9951,10 +9894,10 @@ func (ec *executionContext) unmarshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcar vSlice = graphql.CoerceList(v) } var err error - res := make([]session.HostPlatform, len(vSlice)) + res := make([]*ent.BeaconWhereInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNSessionHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx, vSlice[i]) + res[i], err = ec.unmarshalNBeaconWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -9962,7 +9905,31 @@ func (ec *executionContext) unmarshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcar return res, nil } -func (ec *executionContext) marshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatformᚄ(ctx context.Context, sel ast.SelectionSet, v []session.HostPlatform) graphql.Marshaler { +func (ec *executionContext) unmarshalOBeaconWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeaconWhereInput(ctx context.Context, v interface{}) (*ent.BeaconWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputBeaconWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOCursor2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCursor(ctx context.Context, v interface{}) (*ent.Cursor, error) { + if v == nil { + return nil, nil + } + var res = new(ent.Cursor) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOCursor2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCursor(ctx context.Context, sel ast.SelectionSet, v *ent.Cursor) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalOFile2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.File) graphql.Marshaler { if v == nil { return graphql.Null } @@ -9989,7 +9956,7 @@ func (ec *executionContext) marshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcarre if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNSessionHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx, sel, v[i]) + ret[i] = ec.marshalNFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx, sel, v[i]) } if isLen1 { f(i) @@ -10009,23 +9976,56 @@ func (ec *executionContext) marshalOSessionHostPlatform2ᚕgithubᚗcomᚋkcarre return ret } -func (ec *executionContext) unmarshalOSessionHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx context.Context, v interface{}) (*session.HostPlatform, error) { +func (ec *executionContext) marshalOFile2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFile(ctx context.Context, sel ast.SelectionSet, v *ent.File) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._File(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOFileWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.FileWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.FileWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOFileWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐFileWhereInput(ctx context.Context, v interface{}) (*ent.FileWhereInput, error) { if v == nil { return nil, nil } - var res = new(session.HostPlatform) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) + res, err := ec.unmarshalInputFileWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalOSessionHostPlatform2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx context.Context, sel ast.SelectionSet, v *session.HostPlatform) graphql.Marshaler { +func (ec *executionContext) marshalONode2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v ent.Noder) graphql.Marshaler { if v == nil { return graphql.Null } - return v + return ec._Node(ctx, sel, v) +} + +func (ec *executionContext) marshalOQuest2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuest(ctx context.Context, sel ast.SelectionSet, v *ent.Quest) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Quest(ctx, sel, v) } -func (ec *executionContext) unmarshalOSessionWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.SessionWhereInput, error) { +func (ec *executionContext) unmarshalOQuestWhereInput2ᚕᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.QuestWhereInput, error) { if v == nil { return nil, nil } @@ -10034,10 +10034,10 @@ func (ec *executionContext) unmarshalOSessionWhereInput2ᚕᚖgithubᚗcomᚋkca vSlice = graphql.CoerceList(v) } var err error - res := make([]*ent.SessionWhereInput, len(vSlice)) + res := make([]*ent.QuestWhereInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNSessionWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalNQuestWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -10045,11 +10045,11 @@ func (ec *executionContext) unmarshalOSessionWhereInput2ᚕᚖgithubᚗcomᚋkca return res, nil } -func (ec *executionContext) unmarshalOSessionWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSessionWhereInput(ctx context.Context, v interface{}) (*ent.SessionWhereInput, error) { +func (ec *executionContext) unmarshalOQuestWhereInput2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuestWhereInput(ctx context.Context, v interface{}) (*ent.QuestWhereInput, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputSessionWhereInput(ctx, v) + res, err := ec.unmarshalInputQuestWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } diff --git a/tavern/graphql/generated/inputs.generated.go b/tavern/graphql/generated/inputs.generated.go index 389c85f5a..2958949ae 100644 --- a/tavern/graphql/generated/inputs.generated.go +++ b/tavern/graphql/generated/inputs.generated.go @@ -34,7 +34,7 @@ func (ec *executionContext) unmarshalInputClaimTasksInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"principal", "hostname", "hostPlatform", "hostPrimaryIP", "sessionIdentifier", "hostIdentifier", "agentIdentifier"} + fieldsInOrder := [...]string{"principal", "hostname", "hostPlatform", "hostPrimaryIP", "beaconIdentifier", "hostIdentifier", "agentIdentifier"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -61,7 +61,7 @@ func (ec *executionContext) unmarshalInputClaimTasksInput(ctx context.Context, o var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatform")) - it.HostPlatform, err = ec.unmarshalNSessionHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋsessionᚐHostPlatform(ctx, v) + it.HostPlatform, err = ec.unmarshalNBeaconHostPlatform2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚋbeaconᚐHostPlatform(ctx, v) if err != nil { return it, err } @@ -73,11 +73,11 @@ func (ec *executionContext) unmarshalInputClaimTasksInput(ctx context.Context, o if err != nil { return it, err } - case "sessionIdentifier": + case "beaconIdentifier": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sessionIdentifier")) - it.SessionIdentifier, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("beaconIdentifier")) + it.BeaconIdentifier, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } diff --git a/tavern/graphql/generated/mutation.generated.go b/tavern/graphql/generated/mutation.generated.go index 6799a82c5..5a6cf07a0 100644 --- a/tavern/graphql/generated/mutation.generated.go +++ b/tavern/graphql/generated/mutation.generated.go @@ -17,8 +17,8 @@ import ( // region ************************** generated!.gotpl ************************** type MutationResolver interface { - CreateJob(ctx context.Context, sessionIDs []int, input ent.CreateJobInput) (*ent.Job, error) - UpdateSession(ctx context.Context, sessionID int, input ent.UpdateSessionInput) (*ent.Session, error) + CreateQuest(ctx context.Context, beaconIDs []int, input ent.CreateQuestInput) (*ent.Quest, error) + UpdateBeacon(ctx context.Context, beaconID int, input ent.UpdateBeaconInput) (*ent.Beacon, error) CreateTag(ctx context.Context, input ent.CreateTagInput) (*ent.Tag, error) UpdateTag(ctx context.Context, tagID int, input ent.UpdateTagInput) (*ent.Tag, error) ClaimTasks(ctx context.Context, input models.ClaimTasksInput) ([]*ent.Task, error) @@ -46,22 +46,22 @@ func (ec *executionContext) field_Mutation_claimTasks_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_createJob_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_createQuest_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 []int - if tmp, ok := rawArgs["sessionIDs"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sessionIDs")) + if tmp, ok := rawArgs["beaconIDs"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("beaconIDs")) arg0, err = ec.unmarshalNID2ᚕintᚄ(ctx, tmp) if err != nil { return nil, err } } - args["sessionIDs"] = arg0 - var arg1 ent.CreateJobInput + args["beaconIDs"] = arg0 + var arg1 ent.CreateQuestInput if tmp, ok := rawArgs["input"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg1, err = ec.unmarshalNCreateJobInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateJobInput(ctx, tmp) + arg1, err = ec.unmarshalNCreateQuestInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐCreateQuestInput(ctx, tmp) if err != nil { return nil, err } @@ -115,22 +115,22 @@ func (ec *executionContext) field_Mutation_submitTaskResult_args(ctx context.Con return args, nil } -func (ec *executionContext) field_Mutation_updateSession_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_updateBeacon_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int - if tmp, ok := rawArgs["sessionID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sessionID")) + if tmp, ok := rawArgs["beaconID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("beaconID")) arg0, err = ec.unmarshalNID2int(ctx, tmp) if err != nil { return nil, err } } - args["sessionID"] = arg0 - var arg1 ent.UpdateSessionInput + args["beaconID"] = arg0 + var arg1 ent.UpdateBeaconInput if tmp, ok := rawArgs["input"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg1, err = ec.unmarshalNUpdateSessionInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUpdateSessionInput(ctx, tmp) + arg1, err = ec.unmarshalNUpdateBeaconInput2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐUpdateBeaconInput(ctx, tmp) if err != nil { return nil, err } @@ -195,8 +195,8 @@ func (ec *executionContext) field_Mutation_updateUser_args(ctx context.Context, // region **************************** field.gotpl ***************************** -func (ec *executionContext) _Mutation_createJob(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createJob(ctx, field) +func (ec *executionContext) _Mutation_createQuest(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createQuest(ctx, field) if err != nil { return graphql.Null } @@ -210,7 +210,7 @@ func (ec *executionContext) _Mutation_createJob(ctx context.Context, field graph 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.Mutation().CreateJob(rctx, fc.Args["sessionIDs"].([]int), fc.Args["input"].(ent.CreateJobInput)) + return ec.resolvers.Mutation().CreateQuest(rctx, fc.Args["beaconIDs"].([]int), fc.Args["input"].(ent.CreateQuestInput)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋgraphqlᚋmodelsᚐRole(ctx, "USER") @@ -230,10 +230,10 @@ func (ec *executionContext) _Mutation_createJob(ctx context.Context, field graph if tmp == nil { return nil, nil } - if data, ok := tmp.(*ent.Job); ok { + if data, ok := tmp.(*ent.Quest); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kcarretto/realm/tavern/ent.Job`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kcarretto/realm/tavern/ent.Quest`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -242,12 +242,12 @@ func (ec *executionContext) _Mutation_createJob(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Job) + res := resTmp.(*ent.Quest) fc.Result = res - return ec.marshalOJob2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐJob(ctx, field.Selections, res) + return ec.marshalOQuest2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐQuest(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createJob(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createQuest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -256,25 +256,25 @@ func (ec *executionContext) fieldContext_Mutation_createJob(ctx context.Context, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Job_id(ctx, field) + return ec.fieldContext_Quest_id(ctx, field) case "createdAt": - return ec.fieldContext_Job_createdAt(ctx, field) + return ec.fieldContext_Quest_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Job_lastModifiedAt(ctx, field) + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) case "name": - return ec.fieldContext_Job_name(ctx, field) + return ec.fieldContext_Quest_name(ctx, field) case "parameters": - return ec.fieldContext_Job_parameters(ctx, field) + return ec.fieldContext_Quest_parameters(ctx, field) case "tome": - return ec.fieldContext_Job_tome(ctx, field) + return ec.fieldContext_Quest_tome(ctx, field) case "bundle": - return ec.fieldContext_Job_bundle(ctx, field) + return ec.fieldContext_Quest_bundle(ctx, field) case "tasks": - return ec.fieldContext_Job_tasks(ctx, field) + return ec.fieldContext_Quest_tasks(ctx, field) case "creator": - return ec.fieldContext_Job_creator(ctx, field) + return ec.fieldContext_Quest_creator(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Job", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } defer func() { @@ -284,15 +284,15 @@ func (ec *executionContext) fieldContext_Mutation_createJob(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createJob_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createQuest_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } -func (ec *executionContext) _Mutation_updateSession(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateSession(ctx, field) +func (ec *executionContext) _Mutation_updateBeacon(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateBeacon(ctx, field) if err != nil { return graphql.Null } @@ -306,7 +306,7 @@ func (ec *executionContext) _Mutation_updateSession(ctx context.Context, field g 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.Mutation().UpdateSession(rctx, fc.Args["sessionID"].(int), fc.Args["input"].(ent.UpdateSessionInput)) + return ec.resolvers.Mutation().UpdateBeacon(rctx, fc.Args["beaconID"].(int), fc.Args["input"].(ent.UpdateBeaconInput)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋgraphqlᚋmodelsᚐRole(ctx, "USER") @@ -326,10 +326,10 @@ func (ec *executionContext) _Mutation_updateSession(ctx context.Context, field g if tmp == nil { return nil, nil } - if data, ok := tmp.(*ent.Session); ok { + if data, ok := tmp.(*ent.Beacon); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kcarretto/realm/tavern/ent.Session`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kcarretto/realm/tavern/ent.Beacon`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -341,12 +341,12 @@ func (ec *executionContext) _Mutation_updateSession(ctx context.Context, field g } return graphql.Null } - res := resTmp.(*ent.Session) + res := resTmp.(*ent.Beacon) fc.Result = res - return ec.marshalNSession2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐSession(ctx, field.Selections, res) + return ec.marshalNBeacon2ᚖgithubᚗcomᚋkcarrettoᚋrealmᚋtavernᚋentᚐBeacon(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateSession(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateBeacon(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -355,31 +355,31 @@ func (ec *executionContext) fieldContext_Mutation_updateSession(ctx context.Cont Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Session_id(ctx, field) + return ec.fieldContext_Beacon_id(ctx, field) case "name": - return ec.fieldContext_Session_name(ctx, field) + return ec.fieldContext_Beacon_name(ctx, field) case "principal": - return ec.fieldContext_Session_principal(ctx, field) + return ec.fieldContext_Beacon_principal(ctx, field) case "hostname": - return ec.fieldContext_Session_hostname(ctx, field) + return ec.fieldContext_Beacon_hostname(ctx, field) case "identifier": - return ec.fieldContext_Session_identifier(ctx, field) + return ec.fieldContext_Beacon_identifier(ctx, field) case "agentIdentifier": - return ec.fieldContext_Session_agentIdentifier(ctx, field) + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) case "hostIdentifier": - return ec.fieldContext_Session_hostIdentifier(ctx, field) + return ec.fieldContext_Beacon_hostIdentifier(ctx, field) case "hostPrimaryIP": - return ec.fieldContext_Session_hostPrimaryIP(ctx, field) + return ec.fieldContext_Beacon_hostPrimaryIP(ctx, field) case "hostPlatform": - return ec.fieldContext_Session_hostPlatform(ctx, field) + return ec.fieldContext_Beacon_hostPlatform(ctx, field) case "lastSeenAt": - return ec.fieldContext_Session_lastSeenAt(ctx, field) + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) case "tags": - return ec.fieldContext_Session_tags(ctx, field) + return ec.fieldContext_Beacon_tags(ctx, field) case "tasks": - return ec.fieldContext_Session_tasks(ctx, field) + return ec.fieldContext_Beacon_tasks(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Session", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } defer func() { @@ -389,7 +389,7 @@ func (ec *executionContext) fieldContext_Mutation_updateSession(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateSession_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateBeacon_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } @@ -465,8 +465,8 @@ func (ec *executionContext) fieldContext_Mutation_createTag(ctx context.Context, return ec.fieldContext_Tag_name(ctx, field) case "kind": return ec.fieldContext_Tag_kind(ctx, field) - case "sessions": - return ec.fieldContext_Tag_sessions(ctx, field) + case "beacons": + return ec.fieldContext_Tag_beacons(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, @@ -554,8 +554,8 @@ func (ec *executionContext) fieldContext_Mutation_updateTag(ctx context.Context, return ec.fieldContext_Tag_name(ctx, field) case "kind": return ec.fieldContext_Tag_kind(ctx, field) - case "sessions": - return ec.fieldContext_Tag_sessions(ctx, field) + case "beacons": + return ec.fieldContext_Tag_beacons(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, @@ -629,10 +629,10 @@ func (ec *executionContext) fieldContext_Mutation_claimTasks(ctx context.Context return ec.fieldContext_Task_output(ctx, field) case "error": return ec.fieldContext_Task_error(ctx, field) - case "job": - return ec.fieldContext_Task_job(ctx, field) - case "session": - return ec.fieldContext_Task_session(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, @@ -703,10 +703,10 @@ func (ec *executionContext) fieldContext_Mutation_submitTaskResult(ctx context.C return ec.fieldContext_Task_output(ctx, field) case "error": return ec.fieldContext_Task_error(ctx, field) - case "job": - return ec.fieldContext_Task_job(ctx, field) - case "session": - return ec.fieldContext_Task_session(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, @@ -941,16 +941,16 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") - case "createJob": + case "createQuest": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createJob(ctx, field) + return ec._Mutation_createQuest(ctx, field) }) - case "updateSession": + case "updateBeacon": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateSession(ctx, field) + return ec._Mutation_updateBeacon(ctx, field) }) if out.Values[i] == graphql.Null { diff --git a/tavern/graphql/generated/root_.generated.go b/tavern/graphql/generated/root_.generated.go index 5a7021830..4088290e1 100644 --- a/tavern/graphql/generated/root_.generated.go +++ b/tavern/graphql/generated/root_.generated.go @@ -40,6 +40,21 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + Beacon struct { + AgentIdentifier func(childComplexity int) int + HostIdentifier func(childComplexity int) int + HostPlatform func(childComplexity int) int + HostPrimaryIP func(childComplexity int) int + Hostname func(childComplexity int) int + ID func(childComplexity int) int + Identifier func(childComplexity int) int + LastSeenAt func(childComplexity int) int + Name func(childComplexity int) int + Principal func(childComplexity int) int + Tags func(childComplexity int) int + Tasks func(childComplexity int) int + } + File struct { CreatedAt func(childComplexity int) int Hash func(childComplexity int) int @@ -49,25 +64,13 @@ type ComplexityRoot struct { Size func(childComplexity int) int } - Job struct { - Bundle func(childComplexity int) int - CreatedAt func(childComplexity int) int - Creator func(childComplexity int) int - ID func(childComplexity int) int - LastModifiedAt func(childComplexity int) int - Name func(childComplexity int) int - Parameters func(childComplexity int) int - Tasks func(childComplexity int) int - Tome func(childComplexity int) int - } - Mutation struct { ClaimTasks func(childComplexity int, input models.ClaimTasksInput) int - CreateJob func(childComplexity int, sessionIDs []int, input ent.CreateJobInput) int + CreateQuest func(childComplexity int, beaconIDs []int, input ent.CreateQuestInput) int CreateTag func(childComplexity int, input ent.CreateTagInput) int CreateTome func(childComplexity int, input ent.CreateTomeInput) int SubmitTaskResult func(childComplexity int, input models.SubmitTaskResultInput) int - UpdateSession func(childComplexity int, sessionID int, input ent.UpdateSessionInput) int + UpdateBeacon func(childComplexity int, beaconID int, input ent.UpdateBeaconInput) int UpdateTag func(childComplexity int, tagID int, input ent.UpdateTagInput) int UpdateUser func(childComplexity int, userID int, input ent.UpdateUserInput) int } @@ -80,49 +83,46 @@ type ComplexityRoot struct { } Query struct { - Files func(childComplexity int, where *ent.FileWhereInput) int - Jobs func(childComplexity int, where *ent.JobWhereInput) int - Node func(childComplexity int, id int) int - Nodes func(childComplexity int, ids []int) int - Sessions func(childComplexity int, where *ent.SessionWhereInput) int - Tags func(childComplexity int, where *ent.TagWhereInput) int - Tomes func(childComplexity int, where *ent.TomeWhereInput) int - Users func(childComplexity int, where *ent.UserWhereInput) int + Beacons func(childComplexity int, where *ent.BeaconWhereInput) int + Files func(childComplexity int, where *ent.FileWhereInput) int + Node func(childComplexity int, id int) int + Nodes func(childComplexity int, ids []int) int + Quests func(childComplexity int, where *ent.QuestWhereInput) int + Tags func(childComplexity int, where *ent.TagWhereInput) int + Tomes func(childComplexity int, where *ent.TomeWhereInput) int + Users func(childComplexity int, where *ent.UserWhereInput) int } - Session struct { - AgentIdentifier func(childComplexity int) int - HostIdentifier func(childComplexity int) int - HostPlatform func(childComplexity int) int - HostPrimaryIP func(childComplexity int) int - Hostname func(childComplexity int) int - ID func(childComplexity int) int - Identifier func(childComplexity int) int - LastSeenAt func(childComplexity int) int - Name func(childComplexity int) int - Principal func(childComplexity int) int - Tags func(childComplexity int) int - Tasks func(childComplexity int) int + Quest struct { + Bundle func(childComplexity int) int + CreatedAt func(childComplexity int) int + Creator func(childComplexity int) int + ID func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + Name func(childComplexity int) int + Parameters func(childComplexity int) int + Tasks func(childComplexity int) int + Tome func(childComplexity int) int } Tag struct { - ID func(childComplexity int) int - Kind func(childComplexity int) int - Name func(childComplexity int) int - Sessions func(childComplexity int) int + Beacons func(childComplexity int) int + ID func(childComplexity int) int + Kind func(childComplexity int) int + Name func(childComplexity int) int } Task struct { + Beacon func(childComplexity int) int ClaimedAt func(childComplexity int) int CreatedAt func(childComplexity int) int Error func(childComplexity int) int ExecFinishedAt func(childComplexity int) int ExecStartedAt func(childComplexity int) int ID func(childComplexity int) int - Job func(childComplexity int) int LastModifiedAt func(childComplexity int) int Output func(childComplexity int) int - Session func(childComplexity int) int + Quest func(childComplexity int) int } Tome struct { @@ -160,110 +160,131 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "File.createdAt": - if e.complexity.File.CreatedAt == nil { + case "Beacon.agentIdentifier": + if e.complexity.Beacon.AgentIdentifier == nil { break } - return e.complexity.File.CreatedAt(childComplexity), true + return e.complexity.Beacon.AgentIdentifier(childComplexity), true - case "File.hash": - if e.complexity.File.Hash == nil { + case "Beacon.hostIdentifier": + if e.complexity.Beacon.HostIdentifier == nil { break } - return e.complexity.File.Hash(childComplexity), true + return e.complexity.Beacon.HostIdentifier(childComplexity), true - case "File.id": - if e.complexity.File.ID == nil { + case "Beacon.hostPlatform": + if e.complexity.Beacon.HostPlatform == nil { break } - return e.complexity.File.ID(childComplexity), true + return e.complexity.Beacon.HostPlatform(childComplexity), true - case "File.lastModifiedAt": - if e.complexity.File.LastModifiedAt == nil { + case "Beacon.hostPrimaryIP": + if e.complexity.Beacon.HostPrimaryIP == nil { break } - return e.complexity.File.LastModifiedAt(childComplexity), true + return e.complexity.Beacon.HostPrimaryIP(childComplexity), true - case "File.name": - if e.complexity.File.Name == nil { + case "Beacon.hostname": + if e.complexity.Beacon.Hostname == nil { break } - return e.complexity.File.Name(childComplexity), true + return e.complexity.Beacon.Hostname(childComplexity), true - case "File.size": - if e.complexity.File.Size == nil { + case "Beacon.id": + if e.complexity.Beacon.ID == nil { break } - return e.complexity.File.Size(childComplexity), true + return e.complexity.Beacon.ID(childComplexity), true - case "Job.bundle": - if e.complexity.Job.Bundle == nil { + case "Beacon.identifier": + if e.complexity.Beacon.Identifier == nil { break } - return e.complexity.Job.Bundle(childComplexity), true + return e.complexity.Beacon.Identifier(childComplexity), true - case "Job.createdAt": - if e.complexity.Job.CreatedAt == nil { + case "Beacon.lastSeenAt": + if e.complexity.Beacon.LastSeenAt == nil { break } - return e.complexity.Job.CreatedAt(childComplexity), true + return e.complexity.Beacon.LastSeenAt(childComplexity), true - case "Job.creator": - if e.complexity.Job.Creator == nil { + case "Beacon.name": + if e.complexity.Beacon.Name == nil { break } - return e.complexity.Job.Creator(childComplexity), true + return e.complexity.Beacon.Name(childComplexity), true - case "Job.id": - if e.complexity.Job.ID == nil { + case "Beacon.principal": + if e.complexity.Beacon.Principal == nil { break } - return e.complexity.Job.ID(childComplexity), true + return e.complexity.Beacon.Principal(childComplexity), true - case "Job.lastModifiedAt": - if e.complexity.Job.LastModifiedAt == nil { + case "Beacon.tags": + if e.complexity.Beacon.Tags == nil { break } - return e.complexity.Job.LastModifiedAt(childComplexity), true + return e.complexity.Beacon.Tags(childComplexity), true - case "Job.name": - if e.complexity.Job.Name == nil { + case "Beacon.tasks": + if e.complexity.Beacon.Tasks == nil { break } - return e.complexity.Job.Name(childComplexity), true + return e.complexity.Beacon.Tasks(childComplexity), true - case "Job.parameters": - if e.complexity.Job.Parameters == nil { + case "File.createdAt": + if e.complexity.File.CreatedAt == nil { + break + } + + return e.complexity.File.CreatedAt(childComplexity), true + + case "File.hash": + if e.complexity.File.Hash == nil { + break + } + + return e.complexity.File.Hash(childComplexity), true + + case "File.id": + if e.complexity.File.ID == nil { break } - return e.complexity.Job.Parameters(childComplexity), true + return e.complexity.File.ID(childComplexity), true + + case "File.lastModifiedAt": + if e.complexity.File.LastModifiedAt == nil { + break + } + + return e.complexity.File.LastModifiedAt(childComplexity), true - case "Job.tasks": - if e.complexity.Job.Tasks == nil { + case "File.name": + if e.complexity.File.Name == nil { break } - return e.complexity.Job.Tasks(childComplexity), true + return e.complexity.File.Name(childComplexity), true - case "Job.tome": - if e.complexity.Job.Tome == nil { + case "File.size": + if e.complexity.File.Size == nil { break } - return e.complexity.Job.Tome(childComplexity), true + return e.complexity.File.Size(childComplexity), true case "Mutation.claimTasks": if e.complexity.Mutation.ClaimTasks == nil { @@ -277,17 +298,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.ClaimTasks(childComplexity, args["input"].(models.ClaimTasksInput)), true - case "Mutation.createJob": - if e.complexity.Mutation.CreateJob == nil { + case "Mutation.createQuest": + if e.complexity.Mutation.CreateQuest == nil { break } - args, err := ec.field_Mutation_createJob_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_createQuest_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.CreateJob(childComplexity, args["sessionIDs"].([]int), args["input"].(ent.CreateJobInput)), true + return e.complexity.Mutation.CreateQuest(childComplexity, args["beaconIDs"].([]int), args["input"].(ent.CreateQuestInput)), true case "Mutation.createTag": if e.complexity.Mutation.CreateTag == nil { @@ -325,17 +346,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.SubmitTaskResult(childComplexity, args["input"].(models.SubmitTaskResultInput)), true - case "Mutation.updateSession": - if e.complexity.Mutation.UpdateSession == nil { + case "Mutation.updateBeacon": + if e.complexity.Mutation.UpdateBeacon == nil { break } - args, err := ec.field_Mutation_updateSession_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_updateBeacon_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.UpdateSession(childComplexity, args["sessionID"].(int), args["input"].(ent.UpdateSessionInput)), true + return e.complexity.Mutation.UpdateBeacon(childComplexity, args["beaconID"].(int), args["input"].(ent.UpdateBeaconInput)), true case "Mutation.updateTag": if e.complexity.Mutation.UpdateTag == nil { @@ -389,29 +410,29 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PageInfo.StartCursor(childComplexity), true - case "Query.files": - if e.complexity.Query.Files == nil { + case "Query.beacons": + if e.complexity.Query.Beacons == nil { break } - args, err := ec.field_Query_files_args(context.TODO(), rawArgs) + args, err := ec.field_Query_beacons_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Files(childComplexity, args["where"].(*ent.FileWhereInput)), true + return e.complexity.Query.Beacons(childComplexity, args["where"].(*ent.BeaconWhereInput)), true - case "Query.jobs": - if e.complexity.Query.Jobs == nil { + case "Query.files": + if e.complexity.Query.Files == nil { break } - args, err := ec.field_Query_jobs_args(context.TODO(), rawArgs) + args, err := ec.field_Query_files_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Jobs(childComplexity, args["where"].(*ent.JobWhereInput)), true + return e.complexity.Query.Files(childComplexity, args["where"].(*ent.FileWhereInput)), true case "Query.node": if e.complexity.Query.Node == nil { @@ -437,17 +458,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Nodes(childComplexity, args["ids"].([]int)), true - case "Query.sessions": - if e.complexity.Query.Sessions == nil { + case "Query.quests": + if e.complexity.Query.Quests == nil { break } - args, err := ec.field_Query_sessions_args(context.TODO(), rawArgs) + args, err := ec.field_Query_quests_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Sessions(childComplexity, args["where"].(*ent.SessionWhereInput)), true + return e.complexity.Query.Quests(childComplexity, args["where"].(*ent.QuestWhereInput)), true case "Query.tags": if e.complexity.Query.Tags == nil { @@ -485,89 +506,75 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Users(childComplexity, args["where"].(*ent.UserWhereInput)), true - case "Session.agentIdentifier": - if e.complexity.Session.AgentIdentifier == nil { - break - } - - return e.complexity.Session.AgentIdentifier(childComplexity), true - - case "Session.hostIdentifier": - if e.complexity.Session.HostIdentifier == nil { - break - } - - return e.complexity.Session.HostIdentifier(childComplexity), true - - case "Session.hostPlatform": - if e.complexity.Session.HostPlatform == nil { + case "Quest.bundle": + if e.complexity.Quest.Bundle == nil { break } - return e.complexity.Session.HostPlatform(childComplexity), true + return e.complexity.Quest.Bundle(childComplexity), true - case "Session.hostPrimaryIP": - if e.complexity.Session.HostPrimaryIP == nil { + case "Quest.createdAt": + if e.complexity.Quest.CreatedAt == nil { break } - return e.complexity.Session.HostPrimaryIP(childComplexity), true + return e.complexity.Quest.CreatedAt(childComplexity), true - case "Session.hostname": - if e.complexity.Session.Hostname == nil { + case "Quest.creator": + if e.complexity.Quest.Creator == nil { break } - return e.complexity.Session.Hostname(childComplexity), true + return e.complexity.Quest.Creator(childComplexity), true - case "Session.id": - if e.complexity.Session.ID == nil { + case "Quest.id": + if e.complexity.Quest.ID == nil { break } - return e.complexity.Session.ID(childComplexity), true + return e.complexity.Quest.ID(childComplexity), true - case "Session.identifier": - if e.complexity.Session.Identifier == nil { + case "Quest.lastModifiedAt": + if e.complexity.Quest.LastModifiedAt == nil { break } - return e.complexity.Session.Identifier(childComplexity), true + return e.complexity.Quest.LastModifiedAt(childComplexity), true - case "Session.lastSeenAt": - if e.complexity.Session.LastSeenAt == nil { + case "Quest.name": + if e.complexity.Quest.Name == nil { break } - return e.complexity.Session.LastSeenAt(childComplexity), true + return e.complexity.Quest.Name(childComplexity), true - case "Session.name": - if e.complexity.Session.Name == nil { + case "Quest.parameters": + if e.complexity.Quest.Parameters == nil { break } - return e.complexity.Session.Name(childComplexity), true + return e.complexity.Quest.Parameters(childComplexity), true - case "Session.principal": - if e.complexity.Session.Principal == nil { + case "Quest.tasks": + if e.complexity.Quest.Tasks == nil { break } - return e.complexity.Session.Principal(childComplexity), true + return e.complexity.Quest.Tasks(childComplexity), true - case "Session.tags": - if e.complexity.Session.Tags == nil { + case "Quest.tome": + if e.complexity.Quest.Tome == nil { break } - return e.complexity.Session.Tags(childComplexity), true + return e.complexity.Quest.Tome(childComplexity), true - case "Session.tasks": - if e.complexity.Session.Tasks == nil { + case "Tag.beacons": + if e.complexity.Tag.Beacons == nil { break } - return e.complexity.Session.Tasks(childComplexity), true + return e.complexity.Tag.Beacons(childComplexity), true case "Tag.id": if e.complexity.Tag.ID == nil { @@ -590,12 +597,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Tag.Name(childComplexity), true - case "Tag.sessions": - if e.complexity.Tag.Sessions == nil { + case "Task.beacon": + if e.complexity.Task.Beacon == nil { break } - return e.complexity.Tag.Sessions(childComplexity), true + return e.complexity.Task.Beacon(childComplexity), true case "Task.claimedAt": if e.complexity.Task.ClaimedAt == nil { @@ -639,13 +646,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Task.ID(childComplexity), true - case "Task.job": - if e.complexity.Task.Job == nil { - break - } - - return e.complexity.Task.Job(childComplexity), true - case "Task.lastModifiedAt": if e.complexity.Task.LastModifiedAt == nil { break @@ -660,12 +660,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Task.Output(childComplexity), true - case "Task.session": - if e.complexity.Task.Session == nil { + case "Task.quest": + if e.complexity.Task.Quest == nil { break } - return e.complexity.Task.Session(childComplexity), true + return e.complexity.Task.Quest(childComplexity), true case "Tome.createdAt": if e.complexity.Tome.CreatedAt == nil { @@ -766,16 +766,16 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputBeaconOrder, + ec.unmarshalInputBeaconWhereInput, ec.unmarshalInputClaimTasksInput, - ec.unmarshalInputCreateJobInput, + ec.unmarshalInputCreateQuestInput, ec.unmarshalInputCreateTagInput, ec.unmarshalInputCreateTomeInput, ec.unmarshalInputFileOrder, ec.unmarshalInputFileWhereInput, - ec.unmarshalInputJobOrder, - ec.unmarshalInputJobWhereInput, - ec.unmarshalInputSessionOrder, - ec.unmarshalInputSessionWhereInput, + ec.unmarshalInputQuestOrder, + ec.unmarshalInputQuestWhereInput, ec.unmarshalInputSubmitTaskResultInput, ec.unmarshalInputTagOrder, ec.unmarshalInputTagWhereInput, @@ -783,7 +783,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputTaskWhereInput, ec.unmarshalInputTomeOrder, ec.unmarshalInputTomeWhereInput, - ec.unmarshalInputUpdateSessionInput, + ec.unmarshalInputUpdateBeaconInput, ec.unmarshalInputUpdateTagInput, ec.unmarshalInputUpdateUserInput, ec.unmarshalInputUserWhereInput, @@ -855,83 +855,56 @@ enum Role { }`, BuiltIn: false}, {Name: "../schema/ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -""" -CreateJobInput is used for create Job object. -Input was generated by ent. -""" -input CreateJobInput { - """Name of the job""" - name: String! - """Value of parameters that were specified for the job (as a JSON string).""" - parameters: String - tomeID: ID! -} -""" -CreateTagInput is used for create Tag object. -Input was generated by ent. -""" -input CreateTagInput { - """Name of the tag""" - name: String! - """Describes the type of tag this is""" - kind: TagKind! - sessionIDs: [ID!] -} -""" -CreateTomeInput is used for create Tome object. -Input was generated by ent. -""" -input CreateTomeInput { - """Name of the tome""" - name: String! - """Information about the tome""" - description: String! - """JSON string describing what parameters are used with the tome""" - paramDefs: String - """Eldritch script that will be executed when the tome is run""" - eldritch: String! - fileIDs: [ID!] -} -""" -Define a Relay Cursor type: -https://relay.dev/graphql/connections.htm#sec-Cursor -""" -scalar Cursor -type File implements Node { +type Beacon implements Node { id: ID! - """Timestamp of when this ent was created""" - createdAt: Time! - """Timestamp of when this ent was last updated""" - lastModifiedAt: Time! - """The name of the file, used to reference it for downloads""" + """A human readable identifier for the beacon.""" name: String! - """The size of the file in bytes""" - size: Int! - """A SHA3 digest of the content field""" - hash: String! + """The identity the beacon is authenticated as (e.g. 'root')""" + principal: String + """The hostname of the system the beacon is running on.""" + hostname: String + """Unique identifier for the beacon. Unique to each instance of the beacon.""" + identifier: String! + """Identifies the agent that the beacon is running as (e.g. 'imix').""" + agentIdentifier: String + """Unique identifier for the host the beacon is running on.""" + hostIdentifier: String + """Primary interface IP address reported by the agent.""" + hostPrimaryIP: String + """Platform the agent is operating on.""" + hostPlatform: BeaconHostPlatform! + """Timestamp of when a task was last claimed or updated for the beacon.""" + lastSeenAt: Time + tags: [Tag!] + tasks: [Task!] } -"""Ordering options for File connections""" -input FileOrder { +"""BeaconHostPlatform is enum for the field host_platform""" +enum BeaconHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/beacon.HostPlatform") { + Windows + Linux + MacOS + BSD + Unknown +} +"""Ordering options for Beacon connections""" +input BeaconOrder { """The ordering direction.""" direction: OrderDirection! = ASC - """The field by which to order Files.""" - field: FileOrderField! + """The field by which to order Beacons.""" + field: BeaconOrderField! } -"""Properties by which File connections can be ordered.""" -enum FileOrderField { - CREATED_AT - LAST_MODIFIED_AT - NAME - SIZE +"""Properties by which Beacon connections can be ordered.""" +enum BeaconOrderField { + LAST_SEEN_AT } """ -FileWhereInput is used for filtering File objects. +BeaconWhereInput is used for filtering Beacon objects. Input was generated by ent. """ -input FileWhereInput { - not: FileWhereInput - and: [FileWhereInput!] - or: [FileWhereInput!] +input BeaconWhereInput { + not: BeaconWhereInput + and: [BeaconWhereInput!] + or: [BeaconWhereInput!] """id field predicates""" id: ID idNEQ: ID @@ -941,24 +914,6 @@ input FileWhereInput { 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 """name field predicates""" name: String nameNEQ: String @@ -973,66 +928,200 @@ input FileWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: 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 - hashEqualFold: String - hashContainsFold: String -} -type Job implements Node { - id: ID! - """Timestamp of when this ent was created""" - createdAt: Time! - """Timestamp of when this ent was last updated""" - lastModifiedAt: Time! - """Name of the job""" - name: String! - """Value of parameters that were specified for the job (as a JSON string).""" - parameters: String - tome: Tome! - bundle: File - tasks: [Task!] - creator: User -} -"""Ordering options for Job connections""" -input JobOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Jobs.""" - field: JobOrderField! -} -"""Properties by which Job connections can be ordered.""" -enum JobOrderField { - CREATED_AT - LAST_MODIFIED_AT - NAME -} -""" -JobWhereInput is used for filtering Job objects. + """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 + principalIsNil: Boolean + principalNotNil: Boolean + principalEqualFold: String + principalContainsFold: String + """hostname field predicates""" + hostname: String + hostnameNEQ: String + hostnameIn: [String!] + hostnameNotIn: [String!] + hostnameGT: String + hostnameGTE: String + hostnameLT: String + hostnameLTE: String + hostnameContains: String + hostnameHasPrefix: String + hostnameHasSuffix: String + hostnameIsNil: Boolean + hostnameNotNil: Boolean + hostnameEqualFold: String + hostnameContainsFold: String + """identifier field predicates""" + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """agent_identifier field predicates""" + agentIdentifier: String + agentIdentifierNEQ: String + agentIdentifierIn: [String!] + agentIdentifierNotIn: [String!] + agentIdentifierGT: String + agentIdentifierGTE: String + agentIdentifierLT: String + agentIdentifierLTE: String + agentIdentifierContains: String + agentIdentifierHasPrefix: String + agentIdentifierHasSuffix: String + agentIdentifierIsNil: Boolean + agentIdentifierNotNil: Boolean + agentIdentifierEqualFold: String + agentIdentifierContainsFold: String + """host_identifier field predicates""" + hostIdentifier: String + hostIdentifierNEQ: String + hostIdentifierIn: [String!] + hostIdentifierNotIn: [String!] + hostIdentifierGT: String + hostIdentifierGTE: String + hostIdentifierLT: String + hostIdentifierLTE: String + hostIdentifierContains: String + hostIdentifierHasPrefix: String + hostIdentifierHasSuffix: String + hostIdentifierIsNil: Boolean + hostIdentifierNotNil: Boolean + hostIdentifierEqualFold: String + hostIdentifierContainsFold: String + """host_primary_ip field predicates""" + hostPrimaryIP: String + hostPrimaryIPNEQ: String + hostPrimaryIPIn: [String!] + hostPrimaryIPNotIn: [String!] + hostPrimaryIPGT: String + hostPrimaryIPGTE: String + hostPrimaryIPLT: String + hostPrimaryIPLTE: String + hostPrimaryIPContains: String + hostPrimaryIPHasPrefix: String + hostPrimaryIPHasSuffix: String + hostPrimaryIPIsNil: Boolean + hostPrimaryIPNotNil: Boolean + hostPrimaryIPEqualFold: String + hostPrimaryIPContainsFold: String + """host_platform field predicates""" + hostPlatform: BeaconHostPlatform + hostPlatformNEQ: BeaconHostPlatform + hostPlatformIn: [BeaconHostPlatform!] + hostPlatformNotIn: [BeaconHostPlatform!] + """last_seen_at field predicates""" + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """tags edge predicates""" + hasTags: Boolean + hasTagsWith: [TagWhereInput!] + """tasks edge predicates""" + hasTasks: Boolean + hasTasksWith: [TaskWhereInput!] +} +""" +CreateQuestInput is used for create Quest object. +Input was generated by ent. +""" +input CreateQuestInput { + """Name of the quest""" + name: String! + """Value of parameters that were specified for the quest (as a JSON string).""" + parameters: String + tomeID: ID! +} +""" +CreateTagInput is used for create Tag object. +Input was generated by ent. +""" +input CreateTagInput { + """Name of the tag""" + name: String! + """Describes the type of tag this is""" + kind: TagKind! + beaconIDs: [ID!] +} +""" +CreateTomeInput is used for create Tome object. Input was generated by ent. """ -input JobWhereInput { - not: JobWhereInput - and: [JobWhereInput!] - or: [JobWhereInput!] +input CreateTomeInput { + """Name of the tome""" + name: String! + """Information about the tome""" + description: String! + """JSON string describing what parameters are used with the tome""" + paramDefs: String + """Eldritch script that will be executed when the tome is run""" + eldritch: String! + fileIDs: [ID!] +} +""" +Define a Relay Cursor type: +https://relay.dev/graphql/connections.htm#sec-Cursor +""" +scalar Cursor +type File implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """The name of the file, used to reference it for downloads""" + name: String! + """The size of the file in bytes""" + size: Int! + """A SHA3 digest of the content field""" + hash: String! +} +"""Ordering options for File connections""" +input FileOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Files.""" + field: FileOrderField! +} +"""Properties by which File connections can be ordered.""" +enum FileOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +FileWhereInput is used for filtering File objects. +Input was generated by ent. +""" +input FileWhereInput { + not: FileWhereInput + and: [FileWhereInput!] + or: [FileWhereInput!] """id field predicates""" id: ID idNEQ: ID @@ -1074,34 +1163,29 @@ input JobWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """parameters field predicates""" - parameters: String - parametersNEQ: String - parametersIn: [String!] - parametersNotIn: [String!] - parametersGT: String - parametersGTE: String - parametersLT: String - parametersLTE: String - parametersContains: String - parametersHasPrefix: String - parametersHasSuffix: String - parametersIsNil: Boolean - parametersNotNil: Boolean - parametersEqualFold: String - parametersContainsFold: String - """tome edge predicates""" - hasTome: Boolean - hasTomeWith: [TomeWhereInput!] - """bundle edge predicates""" - hasBundle: Boolean - hasBundleWith: [FileWhereInput!] - """tasks edge predicates""" - hasTasks: Boolean - hasTasksWith: [TaskWhereInput!] - """creator edge predicates""" - hasCreator: Boolean - hasCreatorWith: [UserWhereInput!] + """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 + hashEqualFold: String + hashContainsFold: String } """ An object with an ID. @@ -1144,56 +1228,42 @@ type Query { ids: [ID!]! ): [Node]! } -type Session implements Node { +type Quest implements Node { id: ID! - """A human readable identifier for the session.""" + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """Name of the quest""" name: String! - """The identity the session is authenticated as (e.g. 'root')""" - principal: String - """The hostname of the system the session is running on.""" - hostname: String - """Unique identifier for the session. Unique to each instance of the session.""" - identifier: String! - """Identifies the agent that the session is running as (e.g. 'imix').""" - agentIdentifier: String - """Unique identifier for the host the session is running on.""" - hostIdentifier: String - """Primary interface IP address reported by the agent.""" - hostPrimaryIP: String - """Platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! - """Timestamp of when a task was last claimed or updated for a target""" - lastSeenAt: Time - tags: [Tag!] + """Value of parameters that were specified for the quest (as a JSON string).""" + parameters: String + tome: Tome! + bundle: File tasks: [Task!] + creator: User } -"""SessionHostPlatform is enum for the field host_platform""" -enum SessionHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/session.HostPlatform") { - Windows - Linux - MacOS - BSD - Unknown -} -"""Ordering options for Session connections""" -input SessionOrder { +"""Ordering options for Quest connections""" +input QuestOrder { """The ordering direction.""" direction: OrderDirection! = ASC - """The field by which to order Sessions.""" - field: SessionOrderField! + """The field by which to order Quests.""" + field: QuestOrderField! } -"""Properties by which Session connections can be ordered.""" -enum SessionOrderField { - LAST_SEEN_AT +"""Properties by which Quest connections can be ordered.""" +enum QuestOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME } """ -SessionWhereInput is used for filtering Session objects. +QuestWhereInput is used for filtering Quest objects. Input was generated by ent. """ -input SessionWhereInput { - not: SessionWhereInput - and: [SessionWhereInput!] - or: [SessionWhereInput!] +input QuestWhereInput { + not: QuestWhereInput + and: [QuestWhereInput!] + or: [QuestWhereInput!] """id field predicates""" id: ID idNEQ: ID @@ -1203,6 +1273,24 @@ input SessionWhereInput { 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 """name field predicates""" name: String nameNEQ: String @@ -1217,122 +1305,34 @@ input SessionWhereInput { 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 - principalIsNil: Boolean - principalNotNil: Boolean - principalEqualFold: String - principalContainsFold: String - """hostname field predicates""" - hostname: String - hostnameNEQ: String - hostnameIn: [String!] - hostnameNotIn: [String!] - hostnameGT: String - hostnameGTE: String - hostnameLT: String - hostnameLTE: String - hostnameContains: String - hostnameHasPrefix: String - hostnameHasSuffix: String - hostnameIsNil: Boolean - hostnameNotNil: Boolean - hostnameEqualFold: String - hostnameContainsFold: String - """identifier field predicates""" - identifier: String - identifierNEQ: String - identifierIn: [String!] - identifierNotIn: [String!] - identifierGT: String - identifierGTE: String - identifierLT: String - identifierLTE: String - identifierContains: String - identifierHasPrefix: String - identifierHasSuffix: String - identifierEqualFold: String - identifierContainsFold: String - """agent_identifier field predicates""" - agentIdentifier: String - agentIdentifierNEQ: String - agentIdentifierIn: [String!] - agentIdentifierNotIn: [String!] - agentIdentifierGT: String - agentIdentifierGTE: String - agentIdentifierLT: String - agentIdentifierLTE: String - agentIdentifierContains: String - agentIdentifierHasPrefix: String - agentIdentifierHasSuffix: String - agentIdentifierIsNil: Boolean - agentIdentifierNotNil: Boolean - agentIdentifierEqualFold: String - agentIdentifierContainsFold: String - """host_identifier field predicates""" - hostIdentifier: String - hostIdentifierNEQ: String - hostIdentifierIn: [String!] - hostIdentifierNotIn: [String!] - hostIdentifierGT: String - hostIdentifierGTE: String - hostIdentifierLT: String - hostIdentifierLTE: String - hostIdentifierContains: String - hostIdentifierHasPrefix: String - hostIdentifierHasSuffix: String - hostIdentifierIsNil: Boolean - hostIdentifierNotNil: Boolean - hostIdentifierEqualFold: String - hostIdentifierContainsFold: String - """host_primary_ip field predicates""" - hostPrimaryIP: String - hostPrimaryIPNEQ: String - hostPrimaryIPIn: [String!] - hostPrimaryIPNotIn: [String!] - hostPrimaryIPGT: String - hostPrimaryIPGTE: String - hostPrimaryIPLT: String - hostPrimaryIPLTE: String - hostPrimaryIPContains: String - hostPrimaryIPHasPrefix: String - hostPrimaryIPHasSuffix: String - hostPrimaryIPIsNil: Boolean - hostPrimaryIPNotNil: Boolean - hostPrimaryIPEqualFold: String - hostPrimaryIPContainsFold: String - """host_platform field predicates""" - hostPlatform: SessionHostPlatform - hostPlatformNEQ: SessionHostPlatform - hostPlatformIn: [SessionHostPlatform!] - hostPlatformNotIn: [SessionHostPlatform!] - """last_seen_at field predicates""" - lastSeenAt: Time - lastSeenAtNEQ: Time - lastSeenAtIn: [Time!] - lastSeenAtNotIn: [Time!] - lastSeenAtGT: Time - lastSeenAtGTE: Time - lastSeenAtLT: Time - lastSeenAtLTE: Time - lastSeenAtIsNil: Boolean - lastSeenAtNotNil: Boolean - """tags edge predicates""" - hasTags: Boolean - hasTagsWith: [TagWhereInput!] + """parameters field predicates""" + parameters: String + parametersNEQ: String + parametersIn: [String!] + parametersNotIn: [String!] + parametersGT: String + parametersGTE: String + parametersLT: String + parametersLTE: String + parametersContains: String + parametersHasPrefix: String + parametersHasSuffix: String + parametersIsNil: Boolean + parametersNotNil: Boolean + parametersEqualFold: String + parametersContainsFold: String + """tome edge predicates""" + hasTome: Boolean + hasTomeWith: [TomeWhereInput!] + """bundle edge predicates""" + hasBundle: Boolean + hasBundleWith: [FileWhereInput!] """tasks edge predicates""" hasTasks: Boolean hasTasksWith: [TaskWhereInput!] + """creator edge predicates""" + hasCreator: Boolean + hasCreatorWith: [UserWhereInput!] } type Tag implements Node { id: ID! @@ -1340,7 +1340,7 @@ type Tag implements Node { name: String! """Describes the type of tag this is""" kind: TagKind! - sessions: [Session!] + beacons: [Beacon!] } """TagKind is enum for the field kind""" enum TagKind @goModel(model: "github.com/kcarretto/realm/tavern/ent/tag.Kind") { @@ -1394,9 +1394,9 @@ input TagWhereInput { kindNEQ: TagKind kindIn: [TagKind!] kindNotIn: [TagKind!] - """sessions edge predicates""" - hasSessions: Boolean - hasSessionsWith: [SessionWhereInput!] + """beacons edge predicates""" + hasBeacons: Boolean + hasBeaconsWith: [BeaconWhereInput!] } type Task implements Node { id: ID! @@ -1414,8 +1414,8 @@ type Task implements Node { output: String """Error, if any, produced while executing the Task""" error: String - job: Job! - session: Session! + quest: Quest! + beacon: Beacon! } """Ordering options for Task connections""" input TaskOrder { @@ -1532,12 +1532,12 @@ input TaskWhereInput { errorNotNil: Boolean errorEqualFold: String errorContainsFold: String - """job edge predicates""" - hasJob: Boolean - hasJobWith: [JobWhereInput!] - """session edge predicates""" - hasSession: Boolean - hasSessionWith: [SessionWhereInput!] + """quest edge predicates""" + hasQuest: Boolean + hasQuestWith: [QuestWhereInput!] + """beacon edge predicates""" + hasBeacon: Boolean + hasBeaconWith: [BeaconWhereInput!] } type Tome implements Node { id: ID! @@ -1666,13 +1666,13 @@ input TomeWhereInput { hasFilesWith: [FileWhereInput!] } """ -UpdateSessionInput is used for update Session object. +UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ -input UpdateSessionInput { - """A human readable identifier for the session.""" +input UpdateBeaconInput { + """A human readable identifier for the beacon.""" name: String - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String clearHostname: Boolean addTagIDs: [ID!] @@ -1688,9 +1688,9 @@ input UpdateTagInput { name: String """Describes the type of tag this is""" kind: TagKind - addSessionIDs: [ID!] - removeSessionIDs: [ID!] - clearSessions: Boolean + addBeaconIDs: [ID!] + removeBeaconIDs: [ID!] + clearBeacons: Boolean } """ UpdateUserInput is used for update User object. @@ -1773,22 +1773,22 @@ input UserWhereInput { {Name: "../schema/scalars.graphql", Input: `scalar Time`, BuiltIn: false}, {Name: "../schema/query.graphql", Input: `extend type Query { files(where: FileWhereInput): [File!]! - jobs(where: JobWhereInput): [Job!]! - sessions(where: SessionWhereInput): [Session!]! + quests(where: QuestWhereInput): [Quest!]! + beacons(where: BeaconWhereInput): [Beacon!]! tags(where: TagWhereInput): [Tag!]! tomes(where: TomeWhereInput): [Tome!]! users(where: UserWhereInput): [User!]! }`, BuiltIn: false}, {Name: "../schema/mutation.graphql", Input: `type Mutation { ### - # Job + # Quest ### - createJob(sessionIDs: [ID!]!, input: CreateJobInput!): Job @requireRole(role: USER) + createQuest(beaconIDs: [ID!]!, input: CreateQuestInput!): Quest @requireRole(role: USER) ### - # Session + # Beacon ### - updateSession(sessionID: ID!, input: UpdateSessionInput!): Session! @requireRole(role: USER) + updateBeacon(beaconID: ID!, input: UpdateBeaconInput!): Beacon! @requireRole(role: USER) ### # Tag @@ -1813,25 +1813,25 @@ input UserWhereInput { updateUser(userID: ID!, input: UpdateUserInput!): User @requireRole(role: ADMIN) }`, BuiltIn: false}, {Name: "../schema/inputs.graphql", Input: `input ClaimTasksInput { - """The identity the session is authenticated as (e.g. 'root')""" + """The identity the beacon is authenticated as (e.g. 'root')""" principal: String! - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String! """The platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! + hostPlatform: BeaconHostPlatform! """The IP address of the hosts primary interface (if available).""" hostPrimaryIP: String - """Unique identifier of the session, each running instance will be different.""" - sessionIdentifier: String! + """Unique identifier of the beacon, each running instance will be different.""" + beaconIdentifier: String! - """Unique identifier of the underlying host system the session is running on.""" + """Unique identifier of the underlying host system the beacon is running on.""" hostIdentifier: String! - """Name of the agent program the session is running as (e.g. 'imix')""" + """Name of the agent program the beacon is running as (e.g. 'imix')""" agentIdentifier: String! } diff --git a/tavern/graphql/gqlgen.yml b/tavern/graphql/gqlgen.yml index 02f6d9009..b4ba279bf 100644 --- a/tavern/graphql/gqlgen.yml +++ b/tavern/graphql/gqlgen.yml @@ -28,8 +28,8 @@ autobind: - github.com/kcarretto/realm/tavern/ent/file - github.com/kcarretto/realm/tavern/ent/user - github.com/kcarretto/realm/tavern/ent/tag - - github.com/kcarretto/realm/tavern/ent/session - - github.com/kcarretto/realm/tavern/ent/job + - github.com/kcarretto/realm/tavern/ent/beacon + - github.com/kcarretto/realm/tavern/ent/quest - github.com/kcarretto/realm/tavern/ent/task - github.com/kcarretto/realm/tavern/ent/tome @@ -51,4 +51,4 @@ models: - github.com/kcarretto/realm/tavern/ent/tag.Kind HostPlatform: model: - - github.com/kcarretto/realm/tavern/ent/session.HostPlatform + - github.com/kcarretto/realm/tavern/ent/beacon.HostPlatform diff --git a/tavern/graphql/models/gqlgen_models.go b/tavern/graphql/models/gqlgen_models.go index 17cafe58a..b4ae2928a 100644 --- a/tavern/graphql/models/gqlgen_models.go +++ b/tavern/graphql/models/gqlgen_models.go @@ -8,23 +8,23 @@ import ( "strconv" "time" - "github.com/kcarretto/realm/tavern/ent/session" + "github.com/kcarretto/realm/tavern/ent/beacon" ) type ClaimTasksInput struct { - // The identity the session is authenticated as (e.g. 'root') + // The identity the beacon is authenticated as (e.g. 'root') Principal string `json:"principal"` - // The hostname of the system the session is running on. + // The hostname of the system the beacon is running on. Hostname string `json:"hostname"` // The platform the agent is operating on. - HostPlatform session.HostPlatform `json:"hostPlatform"` + HostPlatform beacon.HostPlatform `json:"hostPlatform"` // The IP address of the hosts primary interface (if available). HostPrimaryIP *string `json:"hostPrimaryIP"` - // Unique identifier of the session, each running instance will be different. - SessionIdentifier string `json:"sessionIdentifier"` - // Unique identifier of the underlying host system the session is running on. + // Unique identifier of the beacon, each running instance will be different. + BeaconIdentifier string `json:"beaconIdentifier"` + // Unique identifier of the underlying host system the beacon is running on. HostIdentifier string `json:"hostIdentifier"` - // Name of the agent program the session is running as (e.g. 'imix') + // Name of the agent program the beacon is running as (e.g. 'imix') AgentIdentifier string `json:"agentIdentifier"` } diff --git a/tavern/graphql/mutation.resolvers.go b/tavern/graphql/mutation.resolvers.go index 737595bbb..dd04e365c 100644 --- a/tavern/graphql/mutation.resolvers.go +++ b/tavern/graphql/mutation.resolvers.go @@ -11,15 +11,15 @@ import ( "github.com/kcarretto/realm/tavern/auth" "github.com/kcarretto/realm/tavern/ent" + "github.com/kcarretto/realm/tavern/ent/beacon" "github.com/kcarretto/realm/tavern/ent/file" - "github.com/kcarretto/realm/tavern/ent/session" "github.com/kcarretto/realm/tavern/ent/task" "github.com/kcarretto/realm/tavern/graphql/generated" "github.com/kcarretto/realm/tavern/graphql/models" ) -// CreateJob is the resolver for the createJob field. -func (r *mutationResolver) CreateJob(ctx context.Context, sessionIDs []int, input ent.CreateJobInput) (*ent.Job, error) { +// CreateQuest is the resolver for the createQuest field. +func (r *mutationResolver) CreateQuest(ctx context.Context, beaconIDs []int, input ent.CreateQuestInput) (*ent.Quest, error) { // 1. Begin Transaction tx, err := r.client.Tx(ctx) if err != nil { @@ -36,13 +36,13 @@ func (r *mutationResolver) CreateJob(ctx context.Context, sessionIDs []int, inpu }() // 3. Load Tome - jobTome, err := client.Tome.Get(ctx, input.TomeID) + questTome, err := client.Tome.Get(ctx, input.TomeID) if err != nil { return nil, rollback(tx, fmt.Errorf("failed to load tome: %w", err)) } // 4. Load Tome Files (ordered so that hashing is always the same) - bundleFiles, err := jobTome.QueryFiles(). + bundleFiles, err := questTome.QueryFiles(). Order(ent.Asc(file.FieldID)). All(ctx) if err != nil { @@ -65,25 +65,25 @@ func (r *mutationResolver) CreateJob(ctx context.Context, sessionIDs []int, inpu creatorID = &creator.ID } - // 7. Create Job - job, err := client.Job.Create(). + // 7. Create Quest + quest, err := client.Quest.Create(). SetInput(input). SetNillableBundleID(bundleID). - SetTome(jobTome). + SetTome(questTome). SetNillableCreatorID(creatorID). Save(ctx) if err != nil { - return nil, rollback(tx, fmt.Errorf("failed to create job: %w", err)) + return nil, rollback(tx, fmt.Errorf("failed to create quest: %w", err)) } - // 8. Create tasks for each session - for _, sid := range sessionIDs { + // 8. Create tasks for each beacon + for _, sid := range beaconIDs { _, err := client.Task.Create(). - SetJob(job). - SetSessionID(sid). + SetQuest(quest). + SetBeaconID(sid). Save(ctx) if err != nil { - return nil, rollback(tx, fmt.Errorf("failed to create task for session (%q): %w", sid, err)) + return nil, rollback(tx, fmt.Errorf("failed to create task for beacon (%q): %w", sid, err)) } } @@ -92,18 +92,18 @@ func (r *mutationResolver) CreateJob(ctx context.Context, sessionIDs []int, inpu return nil, rollback(tx, fmt.Errorf("failed to commit transaction: %w", err)) } - // 10. Load the job with our non transactional client (cannot use transaction after commit) - job, err = r.client.Job.Get(ctx, job.ID) + // 10. Load the quest with our non transactional client (cannot use transaction after commit) + quest, err = r.client.Quest.Get(ctx, quest.ID) if err != nil { - return nil, fmt.Errorf("failed to load created job: %w", err) + return nil, fmt.Errorf("failed to load created quest: %w", err) } - return job, nil + return quest, nil } -// UpdateSession is the resolver for the updateSession field. -func (r *mutationResolver) UpdateSession(ctx context.Context, sessionID int, input ent.UpdateSessionInput) (*ent.Session, error) { - return r.client.Session.UpdateOneID(sessionID).SetInput(input).Save(ctx) +// UpdateBeacon is the resolver for the updateBeacon field. +func (r *mutationResolver) UpdateBeacon(ctx context.Context, beaconID int, input ent.UpdateBeaconInput) (*ent.Beacon, error) { + return r.client.Beacon.UpdateOneID(beaconID).SetInput(input).Save(ctx) } // CreateTag is the resolver for the createTag field. @@ -118,51 +118,51 @@ func (r *mutationResolver) UpdateTag(ctx context.Context, tagID int, input ent.U // ClaimTasks is the resolver for the claimTasks field. func (r *mutationResolver) ClaimTasks(ctx context.Context, input models.ClaimTasksInput) ([]*ent.Task, error) { - // 1. Check if session already exists - agentSession, err := r.client.Session.Query(). - Where(session.Identifier(input.SessionIdentifier)). + // 1. Check if beacon already exists + agentBeacon, err := r.client.Beacon.Query(). + Where(beacon.Identifier(input.BeaconIdentifier)). Only(ctx) if err != nil && !ent.IsNotFound(err) { - return nil, fmt.Errorf("failed to query sessions: %w", err) + return nil, fmt.Errorf("failed to query beacons: %w", err) } - // 2. Create session if it didn't already exist + // 2. Create beacon if it didn't already exist if ent.IsNotFound(err) { - _, err = r.client.Session.Create(). + _, err = r.client.Beacon.Create(). SetPrincipal(input.Principal). SetHostname(input.Hostname). SetNillableHostPrimaryIP(input.HostPrimaryIP). SetHostPlatform(input.HostPlatform). - SetIdentifier(input.SessionIdentifier). + SetIdentifier(input.BeaconIdentifier). SetAgentIdentifier(input.AgentIdentifier). SetHostIdentifier(input.HostIdentifier). SetLastSeenAt(time.Now()). Save(ctx) if err != nil { - return nil, fmt.Errorf("failed to create new session: %w", err) + return nil, fmt.Errorf("failed to create new beacon: %w", err) } - // New sessions won't have any tasks yet, so just return an empty list + // New beacons won't have any tasks yet, so just return an empty list return []*ent.Task{}, nil } - // 3. Update the existing session - agentSession, err = agentSession.Update(). + // 3. Update the existing beacon + agentBeacon, err = agentBeacon.Update(). SetPrincipal(input.Principal). SetHostname(input.Hostname). SetNillableHostPrimaryIP(input.HostPrimaryIP). SetHostPlatform(input.HostPlatform). - SetIdentifier(input.SessionIdentifier). + SetIdentifier(input.BeaconIdentifier). SetAgentIdentifier(input.AgentIdentifier). SetHostIdentifier(input.HostIdentifier). SetLastSeenAt(time.Now()). Save(ctx) if err != nil { - return nil, fmt.Errorf("failed to update existing session: %w", err) + return nil, fmt.Errorf("failed to update existing beacon: %w", err) } - // 4. Load any queued tasks for the session - tasks, err := agentSession.QueryTasks(). + // 4. Load any queued tasks for the beacon + tasks, err := agentBeacon.QueryTasks(). Where(task.ClaimedAtIsNil()). All(ctx) if err != nil { diff --git a/tavern/graphql/query.resolvers.go b/tavern/graphql/query.resolvers.go index 6ce0a2125..553f621df 100644 --- a/tavern/graphql/query.resolvers.go +++ b/tavern/graphql/query.resolvers.go @@ -23,28 +23,28 @@ func (r *queryResolver) Files(ctx context.Context, where *ent.FileWhereInput) ([ return r.client.File.Query().All(ctx) } -// Jobs is the resolver for the jobs field. -func (r *queryResolver) Jobs(ctx context.Context, where *ent.JobWhereInput) ([]*ent.Job, error) { +// Quests is the resolver for the quests field. +func (r *queryResolver) Quests(ctx context.Context, where *ent.QuestWhereInput) ([]*ent.Quest, error) { if where != nil { - query, err := where.Filter(r.client.Job.Query()) + query, err := where.Filter(r.client.Quest.Query()) if err != nil { return nil, fmt.Errorf("failed to apply filter: %w", err) } return query.All(ctx) } - return r.client.Job.Query().All(ctx) + return r.client.Quest.Query().All(ctx) } -// Sessions is the resolver for the sessions field. -func (r *queryResolver) Sessions(ctx context.Context, where *ent.SessionWhereInput) ([]*ent.Session, error) { +// Beacons is the resolver for the beacons field. +func (r *queryResolver) Beacons(ctx context.Context, where *ent.BeaconWhereInput) ([]*ent.Beacon, error) { if where != nil { - query, err := where.Filter(r.client.Session.Query()) + query, err := where.Filter(r.client.Beacon.Query()) if err != nil { return nil, fmt.Errorf("failed to apply filter: %w", err) } return query.All(ctx) } - return r.client.Session.Query().All(ctx) + return r.client.Beacon.Query().All(ctx) } // Tags is the resolver for the tags field. diff --git a/tavern/graphql/query_test.go b/tavern/graphql/query_test.go index 73655bf6b..00358d3ad 100644 --- a/tavern/graphql/query_test.go +++ b/tavern/graphql/query_test.go @@ -69,7 +69,7 @@ func newUsersQueryTest(gqlClient *client.Client, checks ...func(t *testing.T, id } } -func TestJobsQuery(t *testing.T) { +func TestQuestsQuery(t *testing.T) { // Setup ctx := context.Background() graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") @@ -83,12 +83,12 @@ func TestJobsQuery(t *testing.T) { SetDescription("For testing!"). SetEldritch("Testing!"). SaveX(ctx) - testJobs := []*ent.Job{ - graph.Job.Create(). + testQuests := []*ent.Quest{ + graph.Quest.Create(). SetName("Test 1"). SetTome(tome). SaveX(ctx), - graph.Job.Create(). + graph.Quest.Create(). SetName("Test 2"). SetTome(tome). SaveX(ctx), @@ -96,14 +96,14 @@ func TestJobsQuery(t *testing.T) { t.Run("All", func(t *testing.T) { query := ` -query AllJobs($where: JobWhereInput) { - jobs(where: $where) { +query AllQuests($where: QuestWhereInput) { + quests(where: $where) { id } }` - queryJobs := func(where map[string]any) ([]int, error) { + queryQuests := func(where map[string]any) ([]int, error) { var resp struct { - Jobs []struct{ ID string } `json:"jobs"` + Quests []struct{ ID string } `json:"quests"` } if where == nil { where = make(map[string]any) @@ -113,16 +113,16 @@ query AllJobs($where: JobWhereInput) { return nil, err } - ids := make([]int, 0, len(resp.Jobs)) - for _, j := range resp.Jobs { + ids := make([]int, 0, len(resp.Quests)) + for _, j := range resp.Quests { ids = append(ids, convertID(j.ID)) } return ids, nil } - ids, err := queryJobs(nil) + ids, err := queryQuests(nil) require.NoError(t, err) - assert.Contains(t, ids, testJobs[0].ID) - assert.Contains(t, ids, testJobs[1].ID) + assert.Contains(t, ids, testQuests[0].ID) + assert.Contains(t, ids, testQuests[1].ID) }) } diff --git a/tavern/graphql/job_test.go b/tavern/graphql/quest_test.go similarity index 68% rename from tavern/graphql/job_test.go rename to tavern/graphql/quest_test.go index a554e4f94..b0ba83d50 100644 --- a/tavern/graphql/job_test.go +++ b/tavern/graphql/quest_test.go @@ -19,8 +19,8 @@ import ( "github.com/stretchr/testify/require" ) -// TestCreateJob ensures the createJob mutation functions as expected -func TestCreateJob(t *testing.T) { +// TestCreateQuest ensures the createQuest mutation functions as expected +func TestCreateQuest(t *testing.T) { // Setup ctx := context.Background() graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") @@ -29,10 +29,10 @@ func TestCreateJob(t *testing.T) { gqlClient := client.New(srv) // Initialize sample data - testSessions := []*ent.Session{ - graph.Session.Create(). + testBeacons := []*ent.Beacon{ + graph.Beacon.Create(). SaveX(ctx), - graph.Session.Create(). + graph.Beacon.Create(). SaveX(ctx), } testTome := graph.Tome.Create(). @@ -58,35 +58,35 @@ func TestCreateJob(t *testing.T) { AddFiles(testFiles...). SaveX(ctx) - expectedJobParams := `{"exampleParam":"Hello World"}` + expectedQuestParams := `{"exampleParam":"Hello World"}` // Run Tests - t.Run("CreateWithoutFiles", newCreateJobTest( + t.Run("CreateWithoutFiles", newCreateQuestTest( gqlClient, - []int{testSessions[0].ID, testSessions[1].ID}, - ent.CreateJobInput{ - Name: "TestJob", - Parameters: &expectedJobParams, + []int{testBeacons[0].ID, testBeacons[1].ID}, + ent.CreateQuestInput{ + Name: "TestQuest", + Parameters: &expectedQuestParams, TomeID: testTome.ID, }, func(t *testing.T, id int, err error) { require.NoError(t, err) require.NotZero(t, id) - // Ensure job was created with proper fields - job := graph.Job.GetX(ctx, id) - assert.Equal(t, "TestJob", job.Name) - assert.Equal(t, `{"exampleParam":"Hello World"}`, job.Parameters) + // Ensure quest was created with proper fields + quest := graph.Quest.GetX(ctx, id) + assert.Equal(t, "TestQuest", quest.Name) + assert.Equal(t, `{"exampleParam":"Hello World"}`, quest.Parameters) // Ensure tome edge was set - tomeID := job.QueryTome().OnlyIDX(ctx) + tomeID := quest.QueryTome().OnlyIDX(ctx) assert.Equal(t, testTome.ID, tomeID) // Ensure no bundle was created - assert.Empty(t, job.QueryTome().QueryFiles().AllX(ctx)) - assert.False(t, job.QueryBundle().ExistX(ctx)) + assert.Empty(t, quest.QueryTome().QueryFiles().AllX(ctx)) + assert.False(t, quest.QueryBundle().ExistX(ctx)) // Ensure tasks were created properly - tasks := job.QueryTasks().AllX(ctx) + tasks := quest.QueryTasks().AllX(ctx) assert.Len(t, tasks, 2) for i, task := range tasks { assert.WithinRange(t, task.CreatedAt, time.Now().Add(-1*time.Second), time.Now().Add(1*time.Second)) @@ -96,28 +96,28 @@ func TestCreateJob(t *testing.T) { assert.Zero(t, task.ExecFinishedAt) assert.Empty(t, task.Output) assert.Empty(t, task.Error) - assert.Equal(t, job.ID, task.QueryJob().OnlyIDX(ctx)) - assert.Equal(t, testSessions[i].ID, task.QuerySession().OnlyIDX(ctx)) + assert.Equal(t, quest.ID, task.QueryQuest().OnlyIDX(ctx)) + assert.Equal(t, testBeacons[i].ID, task.QueryBeacon().OnlyIDX(ctx)) } }, )) - t.Run("CreateWithFiles", newCreateJobTest( + t.Run("CreateWithFiles", newCreateQuestTest( gqlClient, - []int{testSessions[0].ID, testSessions[1].ID}, - ent.CreateJobInput{ - Name: "TestJobWithFiles", + []int{testBeacons[0].ID, testBeacons[1].ID}, + ent.CreateQuestInput{ + Name: "TestQuestWithFiles", TomeID: testTomeWithFiles.ID, }, func(t *testing.T, id int, err error) { require.NoError(t, err) require.NotZero(t, id) - // Ensure job was created with proper fields - job := graph.Job.GetX(ctx, id) - assert.Equal(t, "TestJobWithFiles", job.Name) + // Ensure quest was created with proper fields + quest := graph.Quest.GetX(ctx, id) + assert.Equal(t, "TestQuestWithFiles", quest.Name) // Ensure bundle was created properly - bundle := job.QueryBundle().OnlyX(ctx) + bundle := quest.QueryBundle().OnlyX(ctx) gr, err := gzip.NewReader(bytes.NewReader(bundle.Content)) require.NoError(t, err) tarReader := tar.NewReader(gr) @@ -135,11 +135,11 @@ func TestCreateJob(t *testing.T) { assert.ErrorIs(t, readerErr, io.EOF) // Ensure these are the only files present // Ensure tome edge was set - tomeID := job.QueryTome().OnlyIDX(ctx) + tomeID := quest.QueryTome().OnlyIDX(ctx) assert.Equal(t, testTomeWithFiles.ID, tomeID) // Ensure tasks were created properly - tasks := job.QueryTasks().AllX(ctx) + tasks := quest.QueryTasks().AllX(ctx) assert.Len(t, tasks, 2) for i, task := range tasks { assert.WithinRange(t, task.CreatedAt, time.Now().Add(-1*time.Second), time.Now().Add(1*time.Second)) @@ -149,17 +149,17 @@ func TestCreateJob(t *testing.T) { assert.Zero(t, task.ExecFinishedAt) assert.Empty(t, task.Output) assert.Empty(t, task.Error) - assert.Equal(t, job.ID, task.QueryJob().OnlyIDX(ctx)) - assert.Equal(t, testSessions[i].ID, task.QuerySession().OnlyIDX(ctx)) + assert.Equal(t, quest.ID, task.QueryQuest().OnlyIDX(ctx)) + assert.Equal(t, testBeacons[i].ID, task.QueryBeacon().OnlyIDX(ctx)) } }, )) } -func newCreateJobTest(gqlClient *client.Client, sessionIDs []int, input ent.CreateJobInput, checks ...func(t *testing.T, id int, err error)) func(t *testing.T) { +func newCreateQuestTest(gqlClient *client.Client, beaconIDs []int, input ent.CreateQuestInput, checks ...func(t *testing.T, id int, err error)) func(t *testing.T) { return func(t *testing.T) { // Define the mutatation for testing, taking the input as a variable - mut := `mutation newCreateJobTest($sessionIDs: [ID!]!, $input: CreateJobInput!) { createJob(sessionIDs:$sessionIDs, input:$input) { + mut := `mutation newCreateQuestTest($beaconIDs: [ID!]!, $input: CreateQuestInput!) { createQuest(beaconIDs:$beaconIDs, input:$input) { id tasks { id @@ -168,7 +168,7 @@ func newCreateJobTest(gqlClient *client.Client, sessionIDs []int, input ent.Crea // Make our request to the GraphQL API var resp struct { - CreateJob struct { + CreateQuest struct { ID string Tasks []struct { ID string @@ -176,7 +176,7 @@ func newCreateJobTest(gqlClient *client.Client, sessionIDs []int, input ent.Crea } } err := gqlClient.Post(mut, &resp, - client.Var("sessionIDs", sessionIDs), + client.Var("beaconIDs", beaconIDs), client.Var("input", map[string]interface{}{ "name": input.Name, "parameters": input.Parameters, @@ -186,7 +186,7 @@ func newCreateJobTest(gqlClient *client.Client, sessionIDs []int, input ent.Crea // Run checks with error (if any) and resulting id for _, check := range checks { - check(t, convertID(resp.CreateJob.ID), err) + check(t, convertID(resp.CreateQuest.ID), err) } } } diff --git a/tavern/graphql/schema.graphql b/tavern/graphql/schema.graphql index 44acd4cd8..aed90d9d6 100644 --- a/tavern/graphql/schema.graphql +++ b/tavern/graphql/schema.graphql @@ -5,14 +5,204 @@ enum Role { USER }directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +type Beacon implements Node { + id: ID! + """A human readable identifier for the beacon.""" + name: String! + """The identity the beacon is authenticated as (e.g. 'root')""" + principal: String + """The hostname of the system the beacon is running on.""" + hostname: String + """Unique identifier for the beacon. Unique to each instance of the beacon.""" + identifier: String! + """Identifies the agent that the beacon is running as (e.g. 'imix').""" + agentIdentifier: String + """Unique identifier for the host the beacon is running on.""" + hostIdentifier: String + """Primary interface IP address reported by the agent.""" + hostPrimaryIP: String + """Platform the agent is operating on.""" + hostPlatform: BeaconHostPlatform! + """Timestamp of when a task was last claimed or updated for the beacon.""" + lastSeenAt: Time + tags: [Tag!] + tasks: [Task!] +} +"""BeaconHostPlatform is enum for the field host_platform""" +enum BeaconHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/beacon.HostPlatform") { + Windows + Linux + MacOS + BSD + Unknown +} +"""Ordering options for Beacon connections""" +input BeaconOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Beacons.""" + field: BeaconOrderField! +} +"""Properties by which Beacon connections can be ordered.""" +enum BeaconOrderField { + LAST_SEEN_AT +} +""" +BeaconWhereInput is used for filtering Beacon objects. +Input was generated by ent. +""" +input BeaconWhereInput { + not: BeaconWhereInput + and: [BeaconWhereInput!] + or: [BeaconWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """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 + principalIsNil: Boolean + principalNotNil: Boolean + principalEqualFold: String + principalContainsFold: String + """hostname field predicates""" + hostname: String + hostnameNEQ: String + hostnameIn: [String!] + hostnameNotIn: [String!] + hostnameGT: String + hostnameGTE: String + hostnameLT: String + hostnameLTE: String + hostnameContains: String + hostnameHasPrefix: String + hostnameHasSuffix: String + hostnameIsNil: Boolean + hostnameNotNil: Boolean + hostnameEqualFold: String + hostnameContainsFold: String + """identifier field predicates""" + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """agent_identifier field predicates""" + agentIdentifier: String + agentIdentifierNEQ: String + agentIdentifierIn: [String!] + agentIdentifierNotIn: [String!] + agentIdentifierGT: String + agentIdentifierGTE: String + agentIdentifierLT: String + agentIdentifierLTE: String + agentIdentifierContains: String + agentIdentifierHasPrefix: String + agentIdentifierHasSuffix: String + agentIdentifierIsNil: Boolean + agentIdentifierNotNil: Boolean + agentIdentifierEqualFold: String + agentIdentifierContainsFold: String + """host_identifier field predicates""" + hostIdentifier: String + hostIdentifierNEQ: String + hostIdentifierIn: [String!] + hostIdentifierNotIn: [String!] + hostIdentifierGT: String + hostIdentifierGTE: String + hostIdentifierLT: String + hostIdentifierLTE: String + hostIdentifierContains: String + hostIdentifierHasPrefix: String + hostIdentifierHasSuffix: String + hostIdentifierIsNil: Boolean + hostIdentifierNotNil: Boolean + hostIdentifierEqualFold: String + hostIdentifierContainsFold: String + """host_primary_ip field predicates""" + hostPrimaryIP: String + hostPrimaryIPNEQ: String + hostPrimaryIPIn: [String!] + hostPrimaryIPNotIn: [String!] + hostPrimaryIPGT: String + hostPrimaryIPGTE: String + hostPrimaryIPLT: String + hostPrimaryIPLTE: String + hostPrimaryIPContains: String + hostPrimaryIPHasPrefix: String + hostPrimaryIPHasSuffix: String + hostPrimaryIPIsNil: Boolean + hostPrimaryIPNotNil: Boolean + hostPrimaryIPEqualFold: String + hostPrimaryIPContainsFold: String + """host_platform field predicates""" + hostPlatform: BeaconHostPlatform + hostPlatformNEQ: BeaconHostPlatform + hostPlatformIn: [BeaconHostPlatform!] + hostPlatformNotIn: [BeaconHostPlatform!] + """last_seen_at field predicates""" + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """tags edge predicates""" + hasTags: Boolean + hasTagsWith: [TagWhereInput!] + """tasks edge predicates""" + hasTasks: Boolean + hasTasksWith: [TaskWhereInput!] +} """ -CreateJobInput is used for create Job object. +CreateQuestInput is used for create Quest object. Input was generated by ent. """ -input CreateJobInput { - """Name of the job""" +input CreateQuestInput { + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tomeID: ID! } @@ -25,7 +215,7 @@ input CreateTagInput { name: String! """Describes the type of tag this is""" kind: TagKind! - sessionIDs: [ID!] + beaconIDs: [ID!] } """ CreateTomeInput is used for create Tome object. @@ -147,42 +337,42 @@ input FileWhereInput { hashEqualFold: String hashContainsFold: String } -type Job implements Node { +type Quest implements Node { id: ID! """Timestamp of when this ent was created""" createdAt: Time! """Timestamp of when this ent was last updated""" lastModifiedAt: Time! - """Name of the job""" + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tome: Tome! bundle: File tasks: [Task!] creator: User } -"""Ordering options for Job connections""" -input JobOrder { +"""Ordering options for Quest connections""" +input QuestOrder { """The ordering direction.""" direction: OrderDirection! = ASC - """The field by which to order Jobs.""" - field: JobOrderField! + """The field by which to order Quests.""" + field: QuestOrderField! } -"""Properties by which Job connections can be ordered.""" -enum JobOrderField { +"""Properties by which Quest connections can be ordered.""" +enum QuestOrderField { CREATED_AT LAST_MODIFIED_AT NAME } """ -JobWhereInput is used for filtering Job objects. +QuestWhereInput is used for filtering Quest objects. Input was generated by ent. """ -input JobWhereInput { - not: JobWhereInput - and: [JobWhereInput!] - or: [JobWhereInput!] +input QuestWhereInput { + not: QuestWhereInput + and: [QuestWhereInput!] + or: [QuestWhereInput!] """id field predicates""" id: ID idNEQ: ID @@ -294,203 +484,13 @@ type Query { ids: [ID!]! ): [Node]! } -type Session implements Node { - id: ID! - """A human readable identifier for the session.""" - name: String! - """The identity the session is authenticated as (e.g. 'root')""" - principal: String - """The hostname of the system the session is running on.""" - hostname: String - """Unique identifier for the session. Unique to each instance of the session.""" - identifier: String! - """Identifies the agent that the session is running as (e.g. 'imix').""" - agentIdentifier: String - """Unique identifier for the host the session is running on.""" - hostIdentifier: String - """Primary interface IP address reported by the agent.""" - hostPrimaryIP: String - """Platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! - """Timestamp of when a task was last claimed or updated for a target""" - lastSeenAt: Time - tags: [Tag!] - tasks: [Task!] -} -"""SessionHostPlatform is enum for the field host_platform""" -enum SessionHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/session.HostPlatform") { - Windows - Linux - MacOS - BSD - Unknown -} -"""Ordering options for Session connections""" -input SessionOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Sessions.""" - field: SessionOrderField! -} -"""Properties by which Session connections can be ordered.""" -enum SessionOrderField { - LAST_SEEN_AT -} -""" -SessionWhereInput is used for filtering Session objects. -Input was generated by ent. -""" -input SessionWhereInput { - not: SessionWhereInput - and: [SessionWhereInput!] - or: [SessionWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """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 - principalIsNil: Boolean - principalNotNil: Boolean - principalEqualFold: String - principalContainsFold: String - """hostname field predicates""" - hostname: String - hostnameNEQ: String - hostnameIn: [String!] - hostnameNotIn: [String!] - hostnameGT: String - hostnameGTE: String - hostnameLT: String - hostnameLTE: String - hostnameContains: String - hostnameHasPrefix: String - hostnameHasSuffix: String - hostnameIsNil: Boolean - hostnameNotNil: Boolean - hostnameEqualFold: String - hostnameContainsFold: String - """identifier field predicates""" - identifier: String - identifierNEQ: String - identifierIn: [String!] - identifierNotIn: [String!] - identifierGT: String - identifierGTE: String - identifierLT: String - identifierLTE: String - identifierContains: String - identifierHasPrefix: String - identifierHasSuffix: String - identifierEqualFold: String - identifierContainsFold: String - """agent_identifier field predicates""" - agentIdentifier: String - agentIdentifierNEQ: String - agentIdentifierIn: [String!] - agentIdentifierNotIn: [String!] - agentIdentifierGT: String - agentIdentifierGTE: String - agentIdentifierLT: String - agentIdentifierLTE: String - agentIdentifierContains: String - agentIdentifierHasPrefix: String - agentIdentifierHasSuffix: String - agentIdentifierIsNil: Boolean - agentIdentifierNotNil: Boolean - agentIdentifierEqualFold: String - agentIdentifierContainsFold: String - """host_identifier field predicates""" - hostIdentifier: String - hostIdentifierNEQ: String - hostIdentifierIn: [String!] - hostIdentifierNotIn: [String!] - hostIdentifierGT: String - hostIdentifierGTE: String - hostIdentifierLT: String - hostIdentifierLTE: String - hostIdentifierContains: String - hostIdentifierHasPrefix: String - hostIdentifierHasSuffix: String - hostIdentifierIsNil: Boolean - hostIdentifierNotNil: Boolean - hostIdentifierEqualFold: String - hostIdentifierContainsFold: String - """host_primary_ip field predicates""" - hostPrimaryIP: String - hostPrimaryIPNEQ: String - hostPrimaryIPIn: [String!] - hostPrimaryIPNotIn: [String!] - hostPrimaryIPGT: String - hostPrimaryIPGTE: String - hostPrimaryIPLT: String - hostPrimaryIPLTE: String - hostPrimaryIPContains: String - hostPrimaryIPHasPrefix: String - hostPrimaryIPHasSuffix: String - hostPrimaryIPIsNil: Boolean - hostPrimaryIPNotNil: Boolean - hostPrimaryIPEqualFold: String - hostPrimaryIPContainsFold: String - """host_platform field predicates""" - hostPlatform: SessionHostPlatform - hostPlatformNEQ: SessionHostPlatform - hostPlatformIn: [SessionHostPlatform!] - hostPlatformNotIn: [SessionHostPlatform!] - """last_seen_at field predicates""" - lastSeenAt: Time - lastSeenAtNEQ: Time - lastSeenAtIn: [Time!] - lastSeenAtNotIn: [Time!] - lastSeenAtGT: Time - lastSeenAtGTE: Time - lastSeenAtLT: Time - lastSeenAtLTE: Time - lastSeenAtIsNil: Boolean - lastSeenAtNotNil: Boolean - """tags edge predicates""" - hasTags: Boolean - hasTagsWith: [TagWhereInput!] - """tasks edge predicates""" - hasTasks: Boolean - hasTasksWith: [TaskWhereInput!] -} type Tag implements Node { id: ID! """Name of the tag""" name: String! """Describes the type of tag this is""" kind: TagKind! - sessions: [Session!] + beacons: [Beacon!] } """TagKind is enum for the field kind""" enum TagKind @goModel(model: "github.com/kcarretto/realm/tavern/ent/tag.Kind") { @@ -544,9 +544,9 @@ input TagWhereInput { kindNEQ: TagKind kindIn: [TagKind!] kindNotIn: [TagKind!] - """sessions edge predicates""" - hasSessions: Boolean - hasSessionsWith: [SessionWhereInput!] + """beacons edge predicates""" + hasBeacons: Boolean + hasBeaconsWith: [BeaconWhereInput!] } type Task implements Node { id: ID! @@ -564,8 +564,8 @@ type Task implements Node { output: String """Error, if any, produced while executing the Task""" error: String - job: Job! - session: Session! + quest: Quest! + beacon: Beacon! } """Ordering options for Task connections""" input TaskOrder { @@ -682,12 +682,12 @@ input TaskWhereInput { errorNotNil: Boolean errorEqualFold: String errorContainsFold: String - """job edge predicates""" - hasJob: Boolean - hasJobWith: [JobWhereInput!] - """session edge predicates""" - hasSession: Boolean - hasSessionWith: [SessionWhereInput!] + """quest edge predicates""" + hasQuest: Boolean + hasQuestWith: [QuestWhereInput!] + """beacon edge predicates""" + hasBeacon: Boolean + hasBeaconWith: [BeaconWhereInput!] } type Tome implements Node { id: ID! @@ -816,13 +816,13 @@ input TomeWhereInput { hasFilesWith: [FileWhereInput!] } """ -UpdateSessionInput is used for update Session object. +UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ -input UpdateSessionInput { - """A human readable identifier for the session.""" +input UpdateBeaconInput { + """A human readable identifier for the beacon.""" name: String - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String clearHostname: Boolean addTagIDs: [ID!] @@ -838,9 +838,9 @@ input UpdateTagInput { name: String """Describes the type of tag this is""" kind: TagKind - addSessionIDs: [ID!] - removeSessionIDs: [ID!] - clearSessions: Boolean + addBeaconIDs: [ID!] + removeBeaconIDs: [ID!] + clearBeacons: Boolean } """ UpdateUserInput is used for update User object. @@ -920,25 +920,25 @@ input UserWhereInput { isAdminNEQ: Boolean } input ClaimTasksInput { - """The identity the session is authenticated as (e.g. 'root')""" + """The identity the beacon is authenticated as (e.g. 'root')""" principal: String! - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String! """The platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! + hostPlatform: BeaconHostPlatform! """The IP address of the hosts primary interface (if available).""" hostPrimaryIP: String - """Unique identifier of the session, each running instance will be different.""" - sessionIdentifier: String! + """Unique identifier of the beacon, each running instance will be different.""" + beaconIdentifier: String! - """Unique identifier of the underlying host system the session is running on.""" + """Unique identifier of the underlying host system the beacon is running on.""" hostIdentifier: String! - """Name of the agent program the session is running as (e.g. 'imix')""" + """Name of the agent program the beacon is running as (e.g. 'imix')""" agentIdentifier: String! } @@ -962,14 +962,14 @@ input SubmitTaskResultInput { error: String }type Mutation { ### - # Job + # Quest ### - createJob(sessionIDs: [ID!]!, input: CreateJobInput!): Job @requireRole(role: USER) + createQuest(beaconIDs: [ID!]!, input: CreateQuestInput!): Quest @requireRole(role: USER) ### - # Session + # Beacon ### - updateSession(sessionID: ID!, input: UpdateSessionInput!): Session! @requireRole(role: USER) + updateBeacon(beaconID: ID!, input: UpdateBeaconInput!): Beacon! @requireRole(role: USER) ### # Tag @@ -994,8 +994,8 @@ input SubmitTaskResultInput { updateUser(userID: ID!, input: UpdateUserInput!): User @requireRole(role: ADMIN) }extend type Query { files(where: FileWhereInput): [File!]! - jobs(where: JobWhereInput): [Job!]! - sessions(where: SessionWhereInput): [Session!]! + quests(where: QuestWhereInput): [Quest!]! + beacons(where: BeaconWhereInput): [Beacon!]! tags(where: TagWhereInput): [Tag!]! tomes(where: TomeWhereInput): [Tome!]! users(where: UserWhereInput): [User!]! diff --git a/tavern/graphql/schema/ent.graphql b/tavern/graphql/schema/ent.graphql index 6191f7b07..8a2a1a038 100644 --- a/tavern/graphql/schema/ent.graphql +++ b/tavern/graphql/schema/ent.graphql @@ -1,13 +1,203 @@ directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +type Beacon implements Node { + id: ID! + """A human readable identifier for the beacon.""" + name: String! + """The identity the beacon is authenticated as (e.g. 'root')""" + principal: String + """The hostname of the system the beacon is running on.""" + hostname: String + """Unique identifier for the beacon. Unique to each instance of the beacon.""" + identifier: String! + """Identifies the agent that the beacon is running as (e.g. 'imix').""" + agentIdentifier: String + """Unique identifier for the host the beacon is running on.""" + hostIdentifier: String + """Primary interface IP address reported by the agent.""" + hostPrimaryIP: String + """Platform the agent is operating on.""" + hostPlatform: BeaconHostPlatform! + """Timestamp of when a task was last claimed or updated for the beacon.""" + lastSeenAt: Time + tags: [Tag!] + tasks: [Task!] +} +"""BeaconHostPlatform is enum for the field host_platform""" +enum BeaconHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/beacon.HostPlatform") { + Windows + Linux + MacOS + BSD + Unknown +} +"""Ordering options for Beacon connections""" +input BeaconOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Beacons.""" + field: BeaconOrderField! +} +"""Properties by which Beacon connections can be ordered.""" +enum BeaconOrderField { + LAST_SEEN_AT +} """ -CreateJobInput is used for create Job object. +BeaconWhereInput is used for filtering Beacon objects. Input was generated by ent. """ -input CreateJobInput { - """Name of the job""" +input BeaconWhereInput { + not: BeaconWhereInput + and: [BeaconWhereInput!] + or: [BeaconWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """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 + principalIsNil: Boolean + principalNotNil: Boolean + principalEqualFold: String + principalContainsFold: String + """hostname field predicates""" + hostname: String + hostnameNEQ: String + hostnameIn: [String!] + hostnameNotIn: [String!] + hostnameGT: String + hostnameGTE: String + hostnameLT: String + hostnameLTE: String + hostnameContains: String + hostnameHasPrefix: String + hostnameHasSuffix: String + hostnameIsNil: Boolean + hostnameNotNil: Boolean + hostnameEqualFold: String + hostnameContainsFold: String + """identifier field predicates""" + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """agent_identifier field predicates""" + agentIdentifier: String + agentIdentifierNEQ: String + agentIdentifierIn: [String!] + agentIdentifierNotIn: [String!] + agentIdentifierGT: String + agentIdentifierGTE: String + agentIdentifierLT: String + agentIdentifierLTE: String + agentIdentifierContains: String + agentIdentifierHasPrefix: String + agentIdentifierHasSuffix: String + agentIdentifierIsNil: Boolean + agentIdentifierNotNil: Boolean + agentIdentifierEqualFold: String + agentIdentifierContainsFold: String + """host_identifier field predicates""" + hostIdentifier: String + hostIdentifierNEQ: String + hostIdentifierIn: [String!] + hostIdentifierNotIn: [String!] + hostIdentifierGT: String + hostIdentifierGTE: String + hostIdentifierLT: String + hostIdentifierLTE: String + hostIdentifierContains: String + hostIdentifierHasPrefix: String + hostIdentifierHasSuffix: String + hostIdentifierIsNil: Boolean + hostIdentifierNotNil: Boolean + hostIdentifierEqualFold: String + hostIdentifierContainsFold: String + """host_primary_ip field predicates""" + hostPrimaryIP: String + hostPrimaryIPNEQ: String + hostPrimaryIPIn: [String!] + hostPrimaryIPNotIn: [String!] + hostPrimaryIPGT: String + hostPrimaryIPGTE: String + hostPrimaryIPLT: String + hostPrimaryIPLTE: String + hostPrimaryIPContains: String + hostPrimaryIPHasPrefix: String + hostPrimaryIPHasSuffix: String + hostPrimaryIPIsNil: Boolean + hostPrimaryIPNotNil: Boolean + hostPrimaryIPEqualFold: String + hostPrimaryIPContainsFold: String + """host_platform field predicates""" + hostPlatform: BeaconHostPlatform + hostPlatformNEQ: BeaconHostPlatform + hostPlatformIn: [BeaconHostPlatform!] + hostPlatformNotIn: [BeaconHostPlatform!] + """last_seen_at field predicates""" + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """tags edge predicates""" + hasTags: Boolean + hasTagsWith: [TagWhereInput!] + """tasks edge predicates""" + hasTasks: Boolean + hasTasksWith: [TaskWhereInput!] +} +""" +CreateQuestInput is used for create Quest object. +Input was generated by ent. +""" +input CreateQuestInput { + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tomeID: ID! } @@ -20,7 +210,7 @@ input CreateTagInput { name: String! """Describes the type of tag this is""" kind: TagKind! - sessionIDs: [ID!] + beaconIDs: [ID!] } """ CreateTomeInput is used for create Tome object. @@ -142,42 +332,83 @@ input FileWhereInput { hashEqualFold: String hashContainsFold: String } -type Job implements Node { +""" +An object with an ID. +Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) +""" +interface Node @goModel(model: "github.com/kcarretto/realm/tavern/ent.Noder") { + """The id of the object.""" + id: ID! +} +"""Possible directions in which to order a list of items when provided an `orderBy` argument.""" +enum OrderDirection { + """Specifies an ascending order for a given `orderBy` argument.""" + ASC + """Specifies a descending order for a given `orderBy` argument.""" + DESC +} +""" +Information about pagination in a connection. +https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo +""" +type PageInfo { + """When paginating forwards, are there more items?""" + hasNextPage: Boolean! + """When paginating backwards, are there more items?""" + hasPreviousPage: Boolean! + """When paginating backwards, the cursor to continue.""" + startCursor: Cursor + """When paginating forwards, the cursor to continue.""" + endCursor: Cursor +} +type Query { + """Fetches an object given its ID.""" + node( + """ID of the object.""" + id: ID! + ): Node + """Lookup nodes by a list of IDs.""" + nodes( + """The list of node IDs.""" + ids: [ID!]! + ): [Node]! +} +type Quest implements Node { id: ID! """Timestamp of when this ent was created""" createdAt: Time! """Timestamp of when this ent was last updated""" lastModifiedAt: Time! - """Name of the job""" + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tome: Tome! bundle: File tasks: [Task!] creator: User } -"""Ordering options for Job connections""" -input JobOrder { +"""Ordering options for Quest connections""" +input QuestOrder { """The ordering direction.""" direction: OrderDirection! = ASC - """The field by which to order Jobs.""" - field: JobOrderField! + """The field by which to order Quests.""" + field: QuestOrderField! } -"""Properties by which Job connections can be ordered.""" -enum JobOrderField { +"""Properties by which Quest connections can be ordered.""" +enum QuestOrderField { CREATED_AT LAST_MODIFIED_AT NAME } """ -JobWhereInput is used for filtering Job objects. +QuestWhereInput is used for filtering Quest objects. Input was generated by ent. """ -input JobWhereInput { - not: JobWhereInput - and: [JobWhereInput!] - or: [JobWhereInput!] +input QuestWhereInput { + not: QuestWhereInput + and: [QuestWhereInput!] + or: [QuestWhereInput!] """id field predicates""" id: ID idNEQ: ID @@ -248,244 +479,13 @@ input JobWhereInput { hasCreator: Boolean hasCreatorWith: [UserWhereInput!] } -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node @goModel(model: "github.com/kcarretto/realm/tavern/ent.Noder") { - """The id of the object.""" - id: ID! -} -"""Possible directions in which to order a list of items when provided an `orderBy` argument.""" -enum OrderDirection { - """Specifies an ascending order for a given `orderBy` argument.""" - ASC - """Specifies a descending order for a given `orderBy` argument.""" - DESC -} -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """When paginating forwards, are there more items?""" - hasNextPage: Boolean! - """When paginating backwards, are there more items?""" - hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" - startCursor: Cursor - """When paginating forwards, the cursor to continue.""" - endCursor: Cursor -} -type Query { - """Fetches an object given its ID.""" - node( - """ID of the object.""" - id: ID! - ): Node - """Lookup nodes by a list of IDs.""" - nodes( - """The list of node IDs.""" - ids: [ID!]! - ): [Node]! -} -type Session implements Node { - id: ID! - """A human readable identifier for the session.""" - name: String! - """The identity the session is authenticated as (e.g. 'root')""" - principal: String - """The hostname of the system the session is running on.""" - hostname: String - """Unique identifier for the session. Unique to each instance of the session.""" - identifier: String! - """Identifies the agent that the session is running as (e.g. 'imix').""" - agentIdentifier: String - """Unique identifier for the host the session is running on.""" - hostIdentifier: String - """Primary interface IP address reported by the agent.""" - hostPrimaryIP: String - """Platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! - """Timestamp of when a task was last claimed or updated for a target""" - lastSeenAt: Time - tags: [Tag!] - tasks: [Task!] -} -"""SessionHostPlatform is enum for the field host_platform""" -enum SessionHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/session.HostPlatform") { - Windows - Linux - MacOS - BSD - Unknown -} -"""Ordering options for Session connections""" -input SessionOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Sessions.""" - field: SessionOrderField! -} -"""Properties by which Session connections can be ordered.""" -enum SessionOrderField { - LAST_SEEN_AT -} -""" -SessionWhereInput is used for filtering Session objects. -Input was generated by ent. -""" -input SessionWhereInput { - not: SessionWhereInput - and: [SessionWhereInput!] - or: [SessionWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """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 - principalIsNil: Boolean - principalNotNil: Boolean - principalEqualFold: String - principalContainsFold: String - """hostname field predicates""" - hostname: String - hostnameNEQ: String - hostnameIn: [String!] - hostnameNotIn: [String!] - hostnameGT: String - hostnameGTE: String - hostnameLT: String - hostnameLTE: String - hostnameContains: String - hostnameHasPrefix: String - hostnameHasSuffix: String - hostnameIsNil: Boolean - hostnameNotNil: Boolean - hostnameEqualFold: String - hostnameContainsFold: String - """identifier field predicates""" - identifier: String - identifierNEQ: String - identifierIn: [String!] - identifierNotIn: [String!] - identifierGT: String - identifierGTE: String - identifierLT: String - identifierLTE: String - identifierContains: String - identifierHasPrefix: String - identifierHasSuffix: String - identifierEqualFold: String - identifierContainsFold: String - """agent_identifier field predicates""" - agentIdentifier: String - agentIdentifierNEQ: String - agentIdentifierIn: [String!] - agentIdentifierNotIn: [String!] - agentIdentifierGT: String - agentIdentifierGTE: String - agentIdentifierLT: String - agentIdentifierLTE: String - agentIdentifierContains: String - agentIdentifierHasPrefix: String - agentIdentifierHasSuffix: String - agentIdentifierIsNil: Boolean - agentIdentifierNotNil: Boolean - agentIdentifierEqualFold: String - agentIdentifierContainsFold: String - """host_identifier field predicates""" - hostIdentifier: String - hostIdentifierNEQ: String - hostIdentifierIn: [String!] - hostIdentifierNotIn: [String!] - hostIdentifierGT: String - hostIdentifierGTE: String - hostIdentifierLT: String - hostIdentifierLTE: String - hostIdentifierContains: String - hostIdentifierHasPrefix: String - hostIdentifierHasSuffix: String - hostIdentifierIsNil: Boolean - hostIdentifierNotNil: Boolean - hostIdentifierEqualFold: String - hostIdentifierContainsFold: String - """host_primary_ip field predicates""" - hostPrimaryIP: String - hostPrimaryIPNEQ: String - hostPrimaryIPIn: [String!] - hostPrimaryIPNotIn: [String!] - hostPrimaryIPGT: String - hostPrimaryIPGTE: String - hostPrimaryIPLT: String - hostPrimaryIPLTE: String - hostPrimaryIPContains: String - hostPrimaryIPHasPrefix: String - hostPrimaryIPHasSuffix: String - hostPrimaryIPIsNil: Boolean - hostPrimaryIPNotNil: Boolean - hostPrimaryIPEqualFold: String - hostPrimaryIPContainsFold: String - """host_platform field predicates""" - hostPlatform: SessionHostPlatform - hostPlatformNEQ: SessionHostPlatform - hostPlatformIn: [SessionHostPlatform!] - hostPlatformNotIn: [SessionHostPlatform!] - """last_seen_at field predicates""" - lastSeenAt: Time - lastSeenAtNEQ: Time - lastSeenAtIn: [Time!] - lastSeenAtNotIn: [Time!] - lastSeenAtGT: Time - lastSeenAtGTE: Time - lastSeenAtLT: Time - lastSeenAtLTE: Time - lastSeenAtIsNil: Boolean - lastSeenAtNotNil: Boolean - """tags edge predicates""" - hasTags: Boolean - hasTagsWith: [TagWhereInput!] - """tasks edge predicates""" - hasTasks: Boolean - hasTasksWith: [TaskWhereInput!] -} type Tag implements Node { id: ID! """Name of the tag""" name: String! """Describes the type of tag this is""" kind: TagKind! - sessions: [Session!] + beacons: [Beacon!] } """TagKind is enum for the field kind""" enum TagKind @goModel(model: "github.com/kcarretto/realm/tavern/ent/tag.Kind") { @@ -539,9 +539,9 @@ input TagWhereInput { kindNEQ: TagKind kindIn: [TagKind!] kindNotIn: [TagKind!] - """sessions edge predicates""" - hasSessions: Boolean - hasSessionsWith: [SessionWhereInput!] + """beacons edge predicates""" + hasBeacons: Boolean + hasBeaconsWith: [BeaconWhereInput!] } type Task implements Node { id: ID! @@ -559,8 +559,8 @@ type Task implements Node { output: String """Error, if any, produced while executing the Task""" error: String - job: Job! - session: Session! + quest: Quest! + beacon: Beacon! } """Ordering options for Task connections""" input TaskOrder { @@ -677,12 +677,12 @@ input TaskWhereInput { errorNotNil: Boolean errorEqualFold: String errorContainsFold: String - """job edge predicates""" - hasJob: Boolean - hasJobWith: [JobWhereInput!] - """session edge predicates""" - hasSession: Boolean - hasSessionWith: [SessionWhereInput!] + """quest edge predicates""" + hasQuest: Boolean + hasQuestWith: [QuestWhereInput!] + """beacon edge predicates""" + hasBeacon: Boolean + hasBeaconWith: [BeaconWhereInput!] } type Tome implements Node { id: ID! @@ -811,13 +811,13 @@ input TomeWhereInput { hasFilesWith: [FileWhereInput!] } """ -UpdateSessionInput is used for update Session object. +UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ -input UpdateSessionInput { - """A human readable identifier for the session.""" +input UpdateBeaconInput { + """A human readable identifier for the beacon.""" name: String - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String clearHostname: Boolean addTagIDs: [ID!] @@ -833,9 +833,9 @@ input UpdateTagInput { name: String """Describes the type of tag this is""" kind: TagKind - addSessionIDs: [ID!] - removeSessionIDs: [ID!] - clearSessions: Boolean + addBeaconIDs: [ID!] + removeBeaconIDs: [ID!] + clearBeacons: Boolean } """ UpdateUserInput is used for update User object. diff --git a/tavern/graphql/schema/inputs.graphql b/tavern/graphql/schema/inputs.graphql index e1e8495d1..4fcbf1aa3 100644 --- a/tavern/graphql/schema/inputs.graphql +++ b/tavern/graphql/schema/inputs.graphql @@ -1,23 +1,23 @@ input ClaimTasksInput { - """The identity the session is authenticated as (e.g. 'root')""" + """The identity the beacon is authenticated as (e.g. 'root')""" principal: String! - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String! """The platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! + hostPlatform: BeaconHostPlatform! """The IP address of the hosts primary interface (if available).""" hostPrimaryIP: String - """Unique identifier of the session, each running instance will be different.""" - sessionIdentifier: String! + """Unique identifier of the beacon, each running instance will be different.""" + beaconIdentifier: String! - """Unique identifier of the underlying host system the session is running on.""" + """Unique identifier of the underlying host system the beacon is running on.""" hostIdentifier: String! - """Name of the agent program the session is running as (e.g. 'imix')""" + """Name of the agent program the beacon is running as (e.g. 'imix')""" agentIdentifier: String! } diff --git a/tavern/graphql/schema/mutation.graphql b/tavern/graphql/schema/mutation.graphql index a6e5666ed..5aaea689c 100644 --- a/tavern/graphql/schema/mutation.graphql +++ b/tavern/graphql/schema/mutation.graphql @@ -1,13 +1,13 @@ type Mutation { ### - # Job + # Quest ### - createJob(sessionIDs: [ID!]!, input: CreateJobInput!): Job @requireRole(role: USER) + createQuest(beaconIDs: [ID!]!, input: CreateQuestInput!): Quest @requireRole(role: USER) ### - # Session + # Beacon ### - updateSession(sessionID: ID!, input: UpdateSessionInput!): Session! @requireRole(role: USER) + updateBeacon(beaconID: ID!, input: UpdateBeaconInput!): Beacon! @requireRole(role: USER) ### # Tag diff --git a/tavern/graphql/schema/query.graphql b/tavern/graphql/schema/query.graphql index 4467a0508..02c70df08 100644 --- a/tavern/graphql/schema/query.graphql +++ b/tavern/graphql/schema/query.graphql @@ -1,7 +1,7 @@ extend type Query { files(where: FileWhereInput): [File!]! - jobs(where: JobWhereInput): [Job!]! - sessions(where: SessionWhereInput): [Session!]! + quests(where: QuestWhereInput): [Quest!]! + beacons(where: BeaconWhereInput): [Beacon!]! tags(where: TagWhereInput): [Tag!]! tomes(where: TomeWhereInput): [Tome!]! users(where: UserWhereInput): [User!]! diff --git a/tavern/graphql/tag_test.go b/tavern/graphql/tag_test.go index d3cbdfdd5..b823c8dfd 100644 --- a/tavern/graphql/tag_test.go +++ b/tavern/graphql/tag_test.go @@ -31,8 +31,8 @@ func TestTagMutations(t *testing.T) { SetName("TestTag1"). SaveX(ctx), } - testSessions := []*ent.Session{ - graph.Session.Create(). + testBeacons := []*ent.Beacon{ + graph.Beacon.Create(). SetPrincipal("admin"). SetAgentIdentifier("TEST"). SetIdentifier("SOME_ID"). @@ -40,7 +40,7 @@ func TestTagMutations(t *testing.T) { SetHostname("SOME_HOSTNAME"). SetLastSeenAt(time.Now().Add(-10 * time.Minute)). SaveX(ctx), - graph.Session.Create(). + graph.Beacon.Create(). SetIdentifier("ANOTHER_ID"). SetLastSeenAt(time.Now().Add(-10 * time.Minute)). AddTags(testTags[0]). @@ -66,9 +66,9 @@ mutation newCreateTagTest($input: CreateTagInput!) { return convertID(resp.CreateTag.ID), nil } - t.Run("WithoutSessions", func(t *testing.T) { + t.Run("WithoutBeacons", func(t *testing.T) { expected := map[string]any{ - "name": "TestTagWithoutSessions", + "name": "TestTagWithoutBeacons", "kind": tag.KindGroup, } id, err := createTag(expected) @@ -78,12 +78,12 @@ mutation newCreateTagTest($input: CreateTagInput!) { assert.Equal(t, expected["name"], testTag.Name) assert.Equal(t, expected["kind"], testTag.Kind) }) - t.Run("WithSessions", func(t *testing.T) { - expectedSessionIDs := []int{testSessions[0].ID} + t.Run("WithBeacons", func(t *testing.T) { + expectedBeaconIDs := []int{testBeacons[0].ID} expected := map[string]any{ - "name": "TestTagWithSessions", - "kind": tag.KindGroup, - "sessionIDs": expectedSessionIDs, + "name": "TestTagWithBeacons", + "kind": tag.KindGroup, + "beaconIDs": expectedBeaconIDs, } id, err := createTag(expected) require.NoError(t, err) @@ -91,10 +91,10 @@ mutation newCreateTagTest($input: CreateTagInput!) { testTag := graph.Tag.GetX(ctx, id) assert.Equal(t, expected["name"], testTag.Name) assert.Equal(t, expected["kind"], testTag.Kind) - testTagSessions, err := testTag.Sessions(ctx) + testTagBeacons, err := testTag.Beacons(ctx) require.NoError(t, err) - assert.Len(t, testTagSessions, 1) - assert.Equal(t, expectedSessionIDs[0], testTagSessions[0].ID) + assert.Len(t, testTagBeacons, 1) + assert.Equal(t, expectedBeaconIDs[0], testTagBeacons[0].ID) }) }) @@ -123,20 +123,20 @@ mutation newUpdateTagTest($tagID: ID!, $input: UpdateTagInput!) { return convertID(resp.UpdateTag.ID), nil } - t.Run("ModifySessions", func(t *testing.T) { - expectedSessionIDs := []int{testSessions[0].ID} + t.Run("ModifyBeacons", func(t *testing.T) { + expectedBeaconIDs := []int{testBeacons[0].ID} expected := map[string]any{ - "addSessionIDs": expectedSessionIDs, - "removeSessionIDs": testSessions[1].ID, + "addBeaconIDs": expectedBeaconIDs, + "removeBeaconIDs": testBeacons[1].ID, } id, err := updateTag(testTags[0].ID, expected) require.NoError(t, err) assert.NotZero(t, id) testTag := graph.Tag.GetX(ctx, id) - testTagSessions, err := testTag.Sessions(ctx) + testTagBeacons, err := testTag.Beacons(ctx) require.NoError(t, err) - assert.Len(t, testTagSessions, 1) - assert.Equal(t, expectedSessionIDs[0], testTagSessions[0].ID) + assert.Len(t, testTagBeacons, 1) + assert.Equal(t, expectedBeaconIDs[0], testTagBeacons[0].ID) }) }) } diff --git a/tavern/graphql/testdata/mutations/claimTasks/ExistingSession.yml b/tavern/graphql/testdata/mutations/claimTasks/ExistingBeacon.yml similarity index 55% rename from tavern/graphql/testdata/mutations/claimTasks/ExistingSession.yml rename to tavern/graphql/testdata/mutations/claimTasks/ExistingBeacon.yml index 539211150..14fcc8ab7 100644 --- a/tavern/graphql/testdata/mutations/claimTasks/ExistingSession.yml +++ b/tavern/graphql/testdata/mutations/claimTasks/ExistingBeacon.yml @@ -1,8 +1,8 @@ state: | - INSERT INTO `sessions` (id, name, identifier) - VALUES (1337,"delightful-lich","EXISTING-SESSION"); + INSERT INTO `beacons` (id, name, identifier) + VALUES (1337,"delightful-lich","EXISTING-BEACON"); query: | - mutation ExistingSession($input: ClaimTasksInput!) { + mutation ExistingBeacon($input: ClaimTasksInput!) { claimTasks(input: $input) { id } @@ -12,7 +12,7 @@ variables: principal: root hostname: some-machine hostPlatform: Linux - sessionIdentifier: EXISTING-SESSION + beaconIdentifier: EXISTING-BEACON hostIdentifier: MY-HOST agentIdentifier: COOL-TEST diff --git a/tavern/graphql/testdata/mutations/claimTasks/Filters.yml b/tavern/graphql/testdata/mutations/claimTasks/Filters.yml index cd16fb0db..1a073fc50 100644 --- a/tavern/graphql/testdata/mutations/claimTasks/Filters.yml +++ b/tavern/graphql/testdata/mutations/claimTasks/Filters.yml @@ -1,19 +1,19 @@ state: | - INSERT INTO `sessions` (id, name, identifier) - VALUES (1337,"delightful-lich","EXISTING-SESSION"); - INSERT INTO `sessions` (id, name, identifier) - VALUES (1338,"bad-boi","BAD-SESSION"); + INSERT INTO `beacons` (id, name, identifier) + VALUES (1337,"delightful-lich","EXISTING-BEACON"); + INSERT INTO `beacons` (id, name, identifier) + VALUES (1338,"bad-boi","BAD-BEACON"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D","print('Hello World!')","abcdefg","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7000,2000,"Test Job","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7000,2000,"Test Quest","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8000,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8001,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8002,1338,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at, claimed_at) + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at, claimed_at) VALUES (8003,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13","2023-03-04 14:51:13"); query: | mutation Filters($input: ClaimTasksInput!) { @@ -26,7 +26,7 @@ variables: principal: root hostname: some-machine hostPlatform: Linux - sessionIdentifier: EXISTING-SESSION + beaconIdentifier: EXISTING-BEACON hostIdentifier: MY-HOST agentIdentifier: COOL-TEST diff --git a/tavern/graphql/testdata/mutations/claimTasks/MultiTask.yml b/tavern/graphql/testdata/mutations/claimTasks/MultiTask.yml index 4899639bc..d559cc3ca 100644 --- a/tavern/graphql/testdata/mutations/claimTasks/MultiTask.yml +++ b/tavern/graphql/testdata/mutations/claimTasks/MultiTask.yml @@ -1,13 +1,13 @@ state: | - INSERT INTO `sessions` (id, name, identifier) - VALUES (1337,"delightful-lich","EXISTING-SESSION"); + INSERT INTO `beacons` (id, name, identifier) + VALUES (1337,"delightful-lich","EXISTING-BEACON"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D","print('Hello World!')","abcdefg","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7000,2000,"Test Job","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7000,2000,"Test Quest","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8000,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8001,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); query: | mutation MutiTask($input: ClaimTasksInput!) { @@ -20,7 +20,7 @@ variables: principal: root hostname: some-machine hostPlatform: Linux - sessionIdentifier: EXISTING-SESSION + beaconIdentifier: EXISTING-BEACON hostIdentifier: MY-HOST agentIdentifier: COOL-TEST diff --git a/tavern/graphql/testdata/mutations/claimTasks/NewSession.yml b/tavern/graphql/testdata/mutations/claimTasks/NewBeacon.yml similarity index 72% rename from tavern/graphql/testdata/mutations/claimTasks/NewSession.yml rename to tavern/graphql/testdata/mutations/claimTasks/NewBeacon.yml index 1da8be831..ce5f0337f 100644 --- a/tavern/graphql/testdata/mutations/claimTasks/NewSession.yml +++ b/tavern/graphql/testdata/mutations/claimTasks/NewBeacon.yml @@ -1,5 +1,5 @@ query: | - mutation NewSession($input: ClaimTasksInput!) { + mutation NewBeacon($input: ClaimTasksInput!) { claimTasks(input: $input) { id } @@ -9,7 +9,7 @@ variables: principal: root hostname: some-machine hostPlatform: Linux - sessionIdentifier: SESSION-IDENTIFIER + beaconIdentifier: BEACON-IDENTIFIER hostIdentifier: MY-HOST agentIdentifier: COOL-TEST diff --git a/tavern/graphql/testdata/mutations/claimTasks/OneTask.yml b/tavern/graphql/testdata/mutations/claimTasks/OneTask.yml index 13f4827dc..33f5ff98f 100644 --- a/tavern/graphql/testdata/mutations/claimTasks/OneTask.yml +++ b/tavern/graphql/testdata/mutations/claimTasks/OneTask.yml @@ -1,11 +1,11 @@ state: | - INSERT INTO `sessions` (id, name, identifier) - VALUES (1337,"delightful-lich","EXISTING-SESSION"); + INSERT INTO `beacons` (id, name, identifier) + VALUES (1337,"delightful-lich","EXISTING-BEACON"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D","print('Hello World!')","abcdefg","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7000,2000,"Test Job","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7000,2000,"Test Quest","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8000,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); query: | mutation OneTask($input: ClaimTasksInput!) { @@ -18,7 +18,7 @@ variables: principal: root hostname: some-machine hostPlatform: Linux - sessionIdentifier: EXISTING-SESSION + beaconIdentifier: EXISTING-BEACON hostIdentifier: MY-HOST agentIdentifier: COOL-TEST diff --git a/tavern/graphql/testdata/mutations/createJob/NoFiles.yml b/tavern/graphql/testdata/mutations/createQuest/NoFiles.yml similarity index 68% rename from tavern/graphql/testdata/mutations/createJob/NoFiles.yml rename to tavern/graphql/testdata/mutations/createQuest/NoFiles.yml index 269b04c5b..b6a2abebe 100644 --- a/tavern/graphql/testdata/mutations/createJob/NoFiles.yml +++ b/tavern/graphql/testdata/mutations/createQuest/NoFiles.yml @@ -1,45 +1,45 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); requestor: session_token: secretToken query: | - mutation CreateJobWithNoFiles($sessionIDs: [ID!]!, $input: CreateJobInput!) { - createJob(sessionIDs:$sessionIDs, input:$input) { + mutation CreateQuestWithNoFiles($beaconIDs: [ID!]!, $input: CreateQuestInput!) { + createQuest(beaconIDs:$beaconIDs, input:$input) { name tome { id name } tasks { - session { + beacon { id } - job { + quest { name } } } } variables: - sessionIDs: + beaconIDs: - 1337 input: - name: "WonderfulJob" + name: "WonderfulQuest" tomeID: "2000" expected: - createJob: - name: "WonderfulJob" + createQuest: + name: "WonderfulQuest" tome: id: "2000" name: "Test Tome" tasks: - - session: + - beacon: id: "1337" - job: - name: "WonderfulJob" \ No newline at end of file + quest: + name: "WonderfulQuest" \ No newline at end of file diff --git a/tavern/graphql/testdata/mutations/createJob/WithFiles.yml b/tavern/graphql/testdata/mutations/createQuest/WithFiles.yml similarity index 79% rename from tavern/graphql/testdata/mutations/createJob/WithFiles.yml rename to tavern/graphql/testdata/mutations/createQuest/WithFiles.yml index d0d797d3e..2a590f724 100644 --- a/tavern/graphql/testdata/mutations/createJob/WithFiles.yml +++ b/tavern/graphql/testdata/mutations/createQuest/WithFiles.yml @@ -1,7 +1,7 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); @@ -13,8 +13,8 @@ state: | requestor: session_token: secretToken query: | - mutation CreateJobWithNoFiles($sessionIDs: [ID!]!, $input: CreateJobInput!) { - createJob(sessionIDs:$sessionIDs, input:$input) { + mutation CreateQuestWithNoFiles($beaconIDs: [ID!]!, $input: CreateQuestInput!) { + createQuest(beaconIDs:$beaconIDs, input:$input) { name tome { id @@ -24,10 +24,10 @@ query: | } } tasks { - session { + beacon { id } - job { + quest { name } } @@ -37,15 +37,15 @@ query: | } } variables: - sessionIDs: + beaconIDs: - 1337 input: - name: "WonderfulJob" + name: "WonderfulQuest" tomeID: "2000" expected: - createJob: - name: "WonderfulJob" + createQuest: + name: "WonderfulQuest" tome: id: "2000" name: "Test Tome" @@ -53,9 +53,9 @@ expected: - id: "3000" - id: "3001" tasks: - - session: + - beacon: id: "1337" - job: - name: "WonderfulJob" + quest: + name: "WonderfulQuest" bundle: hash: "4469e68357aa4abc056aa32c248c0912c9f921aba75a960725b2070bc1fad130" \ No newline at end of file diff --git a/tavern/graphql/testdata/mutations/createTag/Group.yml b/tavern/graphql/testdata/mutations/createTag/Group.yml index 941aa175a..efdd1fe37 100644 --- a/tavern/graphql/testdata/mutations/createTag/Group.yml +++ b/tavern/graphql/testdata/mutations/createTag/Group.yml @@ -1,7 +1,7 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); requestor: session_token: secretToken @@ -10,7 +10,7 @@ query: | createTag(input: $input) { name kind - sessions { + beacons { id } } @@ -19,11 +19,11 @@ variables: input: name: "TestTag" kind: "group" - sessionIDs: + beaconIDs: - 1337 expected: createTag: name: "TestTag" kind: "group" - sessions: + beacons: - id: "1337" \ No newline at end of file diff --git a/tavern/graphql/testdata/mutations/createTag/MultipleSessions.yml b/tavern/graphql/testdata/mutations/createTag/MultipleBeacons.yml similarity index 81% rename from tavern/graphql/testdata/mutations/createTag/MultipleSessions.yml rename to tavern/graphql/testdata/mutations/createTag/MultipleBeacons.yml index df969b7f4..970905c4b 100644 --- a/tavern/graphql/testdata/mutations/createTag/MultipleSessions.yml +++ b/tavern/graphql/testdata/mutations/createTag/MultipleBeacons.yml @@ -1,9 +1,9 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); - INSERT INTO `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (420,"lovely-emu","ZYXWVUT-987654"); requestor: session_token: secretToken @@ -12,7 +12,7 @@ query: | createTag(input: $input) { name kind - sessions { + beacons { id } } @@ -21,13 +21,13 @@ variables: input: name: "TestTag" kind: "service" - sessionIDs: + beaconIDs: - 1337 - 420 expected: createTag: name: "TestTag" kind: "service" - sessions: + beacons: - id: "1337" - id: "420" diff --git a/tavern/graphql/testdata/mutations/createTag/Service.yml b/tavern/graphql/testdata/mutations/createTag/Service.yml index 1872b40d6..5671ae2ab 100644 --- a/tavern/graphql/testdata/mutations/createTag/Service.yml +++ b/tavern/graphql/testdata/mutations/createTag/Service.yml @@ -1,7 +1,7 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); requestor: session_token: secretToken @@ -10,7 +10,7 @@ query: | createTag(input: $input) { name kind - sessions { + beacons { id } } @@ -19,11 +19,11 @@ variables: input: name: "TestTag" kind: "service" - sessionIDs: + beaconIDs: - 1337 expected: createTag: name: "TestTag" kind: "service" - sessions: + beacons: - id: "1337" \ No newline at end of file diff --git a/tavern/graphql/testdata/mutations/createTome/WithFiles.yml b/tavern/graphql/testdata/mutations/createTome/WithFiles.yml index 84a585afc..118b24ba4 100644 --- a/tavern/graphql/testdata/mutations/createTome/WithFiles.yml +++ b/tavern/graphql/testdata/mutations/createTome/WithFiles.yml @@ -1,7 +1,7 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) VALUES (3000,"TestFile1", "hello world", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); diff --git a/tavern/graphql/testdata/mutations/submitTaskResult/Append.yml b/tavern/graphql/testdata/mutations/submitTaskResult/Append.yml index ff2835f57..14aefa0e5 100644 --- a/tavern/graphql/testdata/mutations/submitTaskResult/Append.yml +++ b/tavern/graphql/testdata/mutations/submitTaskResult/Append.yml @@ -1,13 +1,13 @@ state: | - INSERT INTO `sessions` (id, name, identifier) - VALUES (1337,"delightful-lich","EXISTING-SESSION"); + INSERT INTO `beacons` (id, name, identifier) + VALUES (1337,"delightful-lich","EXISTING-BEACON"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D","print('Hello World!')","abcdefg","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7000,2000,"Test Job","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7000,2000,"Test Quest","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8000,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at, output) + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at, output) VALUES (8001,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13", "one"); query: | mutation Append($input: SubmitTaskResultInput!) { diff --git a/tavern/graphql/testdata/mutations/submitTaskResult/OneAndDone.yml b/tavern/graphql/testdata/mutations/submitTaskResult/OneAndDone.yml index ebbfeb55f..9f18d77a0 100644 --- a/tavern/graphql/testdata/mutations/submitTaskResult/OneAndDone.yml +++ b/tavern/graphql/testdata/mutations/submitTaskResult/OneAndDone.yml @@ -1,13 +1,13 @@ state: | - INSERT INTO `sessions` (id, name, identifier) - VALUES (1337,"delightful-lich","EXISTING-SESSION"); + INSERT INTO `beacons` (id, name, identifier) + VALUES (1337,"delightful-lich","EXISTING-BEACON"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D","print('Hello World!')","abcdefg","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7000,2000,"Test Job","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7000,2000,"Test Quest","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8000,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `tasks` (id, task_session, job_tasks, created_at, last_modified_at) + INSERT INTO `tasks` (id, task_beacon, quest_tasks, created_at, last_modified_at) VALUES (8001,1337,7000,"2023-03-04 14:51:13","2023-03-04 14:51:13"); query: | mutation Complete($input: SubmitTaskResultInput!) { diff --git a/tavern/graphql/testdata/mutations/updateSession/AddTag.yml b/tavern/graphql/testdata/mutations/updateBeacon/AddTag.yml similarity index 70% rename from tavern/graphql/testdata/mutations/updateSession/AddTag.yml rename to tavern/graphql/testdata/mutations/updateBeacon/AddTag.yml index 60917cf55..d17233c64 100644 --- a/tavern/graphql/testdata/mutations/updateSession/AddTag.yml +++ b/tavern/graphql/testdata/mutations/updateBeacon/AddTag.yml @@ -1,15 +1,15 @@ 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 `sessions` (id, name, hostname, identifier) + INSERT INTO `beacons` (id, name, hostname, identifier) VALUES (1337,"delightful-lich","boring","ABCDEFG-123456"); INSERT INTO `tags` (id, name, kind) VALUES (4000,"very-neat-tag","group"); requestor: session_token: secretToken query: | - mutation AddTag($sessionID: ID!, $input: UpdateSessionInput!) { - updateSession(sessionID: $sessionID, input: $input) { + mutation AddTag($beaconID: ID!, $input: UpdateBeaconInput!) { + updateBeacon(beaconID: $beaconID, input: $input) { id tags { id @@ -17,13 +17,13 @@ query: | } } variables: - sessionID: 1337 + beaconID: 1337 input: addTagIDs: - 4000 expected: - updateSession: + updateBeacon: id: "1337" tags: - id: "4000" \ No newline at end of file diff --git a/tavern/graphql/testdata/mutations/updateSession/ChangeHostname.yml b/tavern/graphql/testdata/mutations/updateBeacon/ChangeHostname.yml similarity index 65% rename from tavern/graphql/testdata/mutations/updateSession/ChangeHostname.yml rename to tavern/graphql/testdata/mutations/updateBeacon/ChangeHostname.yml index 49415be2e..1f401001e 100644 --- a/tavern/graphql/testdata/mutations/updateSession/ChangeHostname.yml +++ b/tavern/graphql/testdata/mutations/updateBeacon/ChangeHostname.yml @@ -1,23 +1,23 @@ 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 `sessions` (id, name, hostname, identifier) + INSERT INTO `beacons` (id, name, hostname, identifier) VALUES (1337,"delightful-lich","boring","ABCDEFG-123456"); requestor: session_token: secretToken query: | - mutation ChangeHostname($sessionID: ID!, $input: UpdateSessionInput!) { - updateSession(sessionID: $sessionID, input: $input) { + mutation ChangeHostname($beaconID: ID!, $input: UpdateBeaconInput!) { + updateBeacon(beaconID: $beaconID, input: $input) { id hostname } } variables: - sessionID: 1337 + beaconID: 1337 input: hostname: "CoolNewName" expected: - updateSession: + updateBeacon: id: "1337" hostname: "CoolNewName" \ No newline at end of file diff --git a/tavern/graphql/testdata/mutations/updateSession/RemoveTag.yml b/tavern/graphql/testdata/mutations/updateBeacon/RemoveTag.yml similarity index 66% rename from tavern/graphql/testdata/mutations/updateSession/RemoveTag.yml rename to tavern/graphql/testdata/mutations/updateBeacon/RemoveTag.yml index 13b5b444b..db1bf8b90 100644 --- a/tavern/graphql/testdata/mutations/updateSession/RemoveTag.yml +++ b/tavern/graphql/testdata/mutations/updateBeacon/RemoveTag.yml @@ -1,17 +1,17 @@ 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 `sessions` (id, name, hostname, identifier) + INSERT INTO `beacons` (id, name, hostname, identifier) VALUES (1337,"delightful-lich","boring","ABCDEFG-123456"); INSERT INTO `tags` (id, name, kind) VALUES (4000,"very-neat-tag","group"); - INSERT INTO `session_tags` (session_id, tag_id) + INSERT INTO `beacon_tags` (beacon_id, tag_id) VALUES (1337,4000); requestor: session_token: secretToken query: | - mutation RemoveTag($sessionID: ID!, $input: UpdateSessionInput!) { - updateSession(sessionID: $sessionID, input: $input) { + mutation RemoveTag($beaconID: ID!, $input: UpdateBeaconInput!) { + updateBeacon(beaconID: $beaconID, input: $input) { id tags { id @@ -19,12 +19,12 @@ query: | } } variables: - sessionID: 1337 + beaconID: 1337 input: removeTagIDs: - 4000 expected: - updateSession: + updateBeacon: id: "1337" tags: [] diff --git a/tavern/graphql/testdata/mutations/updateTag/ChangeName.yml b/tavern/graphql/testdata/mutations/updateTag/ChangeName.yml index 8dc5e25dd..92cf5f6a6 100644 --- a/tavern/graphql/testdata/mutations/updateTag/ChangeName.yml +++ b/tavern/graphql/testdata/mutations/updateTag/ChangeName.yml @@ -1,7 +1,7 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); INSERT INTO `tags` (id, name, kind) VALUES (4000,"boring-tag","group"); diff --git a/tavern/graphql/testdata/queries/sessions/FilterByID.yml b/tavern/graphql/testdata/queries/beacons/FilterByID.yml similarity index 68% rename from tavern/graphql/testdata/queries/sessions/FilterByID.yml rename to tavern/graphql/testdata/queries/beacons/FilterByID.yml index 0884d3cf4..4605be6f5 100644 --- a/tavern/graphql/testdata/queries/sessions/FilterByID.yml +++ b/tavern/graphql/testdata/queries/beacons/FilterByID.yml @@ -1,18 +1,18 @@ 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 `sessions` (id, name, hostname, identifier) + INSERT INTO `beacons` (id, name, hostname, identifier) VALUES (1337,"delightful-lich","boring","ABCDEFG-123456"); - INSERT INTO `sessions` (id, name, hostname, identifier) + INSERT INTO `beacons` (id, name, hostname, identifier) VALUES (1338,"filtered-lich","boring","123456-ZYX"); requestor: session_token: secretToken query: | - query Sessions { - sessions(where: {id: 1337}) { + query Beacons { + beacons(where: {id: 1337}) { id } } expected: - sessions: + beacons: - id: "1337" \ No newline at end of file diff --git a/tavern/graphql/testdata/queries/sessions/Singular.yml b/tavern/graphql/testdata/queries/beacons/Singular.yml similarity index 76% rename from tavern/graphql/testdata/queries/sessions/Singular.yml rename to tavern/graphql/testdata/queries/beacons/Singular.yml index 304eca0e2..51ec0c399 100644 --- a/tavern/graphql/testdata/queries/sessions/Singular.yml +++ b/tavern/graphql/testdata/queries/beacons/Singular.yml @@ -1,16 +1,16 @@ 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 `sessions` (id, name, hostname, identifier) + INSERT INTO `beacons` (id, name, hostname, identifier) VALUES (1337,"delightful-lich","boring","ABCDEFG-123456"); requestor: session_token: secretToken query: | - query Sessions { - sessions { + query Beacons { + beacons { id } } expected: - sessions: + beacons: - id: "1337" \ No newline at end of file diff --git a/tavern/graphql/testdata/queries/jobs/FilterByID.yml b/tavern/graphql/testdata/queries/quests/FilterByID.yml similarity index 58% rename from tavern/graphql/testdata/queries/jobs/FilterByID.yml rename to tavern/graphql/testdata/queries/quests/FilterByID.yml index f8f48c4ed..93dc3ca80 100644 --- a/tavern/graphql/testdata/queries/jobs/FilterByID.yml +++ b/tavern/graphql/testdata/queries/quests/FilterByID.yml @@ -1,22 +1,22 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7000,2000,"Test Job","2023-03-04 14:51:13","2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7001,2000,"Test Job 2","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7000,2000,"Test Quest","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7001,2000,"Test Quest 2","2023-03-04 14:51:13","2023-03-04 14:51:13"); requestor: session_token: secretToken query: | - query Jobs { - jobs(where: {id: 7000}) { + query Quests { + quests(where: {id: 7000}) { id } } expected: - jobs: + quests: - id: "7000" \ No newline at end of file diff --git a/tavern/graphql/testdata/queries/jobs/Singular.yml b/tavern/graphql/testdata/queries/quests/Singular.yml similarity index 69% rename from tavern/graphql/testdata/queries/jobs/Singular.yml rename to tavern/graphql/testdata/queries/quests/Singular.yml index 339b642e6..9f5c36a05 100644 --- a/tavern/graphql/testdata/queries/jobs/Singular.yml +++ b/tavern/graphql/testdata/queries/quests/Singular.yml @@ -1,20 +1,20 @@ 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 `sessions` (id, name, identifier) + INSERT INTO `beacons` (id, name, identifier) VALUES (1337,"delightful-lich","ABCDEFG-123456"); INSERT INTO `tomes` (id, name, description, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); - INSERT INTO `jobs` (id, job_tome, name, created_at, last_modified_at) - VALUES (7000,2000,"Test Job","2023-03-04 14:51:13","2023-03-04 14:51:13"); + INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) + VALUES (7000,2000,"Test Quest","2023-03-04 14:51:13","2023-03-04 14:51:13"); requestor: session_token: secretToken query: | - query Jobs { - jobs { + query Quests { + quests { id } } expected: - jobs: + quests: - id: "7000" \ No newline at end of file diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 44acd4cd8..eacec8b4e 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -5,14 +5,204 @@ enum Role { USER }directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +type Beacon implements Node { + id: ID! + """A human readable identifier for the beacon.""" + name: String! + """The identity the beacon is authenticated as (e.g. 'root')""" + principal: String + """The hostname of the system the beacon is running on.""" + hostname: String + """Unique identifier for the beacon. Unique to each instance of the beacon.""" + identifier: String! + """Identifies the agent that the beacon is running as (e.g. 'imix').""" + agentIdentifier: String + """Unique identifier for the host the beacon is running on.""" + hostIdentifier: String + """Primary interface IP address reported by the agent.""" + hostPrimaryIP: String + """Platform the agent is operating on.""" + hostPlatform: BeaconHostPlatform! + """Timestamp of when a task was last claimed or updated for the beacon.""" + lastSeenAt: Time + tags: [Tag!] + tasks: [Task!] +} +"""BeaconHostPlatform is enum for the field host_platform""" +enum BeaconHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/beacon.HostPlatform") { + Windows + Linux + MacOS + BSD + Unknown +} +"""Ordering options for Beacon connections""" +input BeaconOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Beacons.""" + field: BeaconOrderField! +} +"""Properties by which Beacon connections can be ordered.""" +enum BeaconOrderField { + LAST_SEEN_AT +} """ -CreateJobInput is used for create Job object. +BeaconWhereInput is used for filtering Beacon objects. Input was generated by ent. """ -input CreateJobInput { - """Name of the job""" +input BeaconWhereInput { + not: BeaconWhereInput + and: [BeaconWhereInput!] + or: [BeaconWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """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 + principalIsNil: Boolean + principalNotNil: Boolean + principalEqualFold: String + principalContainsFold: String + """hostname field predicates""" + hostname: String + hostnameNEQ: String + hostnameIn: [String!] + hostnameNotIn: [String!] + hostnameGT: String + hostnameGTE: String + hostnameLT: String + hostnameLTE: String + hostnameContains: String + hostnameHasPrefix: String + hostnameHasSuffix: String + hostnameIsNil: Boolean + hostnameNotNil: Boolean + hostnameEqualFold: String + hostnameContainsFold: String + """identifier field predicates""" + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """agent_identifier field predicates""" + agentIdentifier: String + agentIdentifierNEQ: String + agentIdentifierIn: [String!] + agentIdentifierNotIn: [String!] + agentIdentifierGT: String + agentIdentifierGTE: String + agentIdentifierLT: String + agentIdentifierLTE: String + agentIdentifierContains: String + agentIdentifierHasPrefix: String + agentIdentifierHasSuffix: String + agentIdentifierIsNil: Boolean + agentIdentifierNotNil: Boolean + agentIdentifierEqualFold: String + agentIdentifierContainsFold: String + """host_identifier field predicates""" + hostIdentifier: String + hostIdentifierNEQ: String + hostIdentifierIn: [String!] + hostIdentifierNotIn: [String!] + hostIdentifierGT: String + hostIdentifierGTE: String + hostIdentifierLT: String + hostIdentifierLTE: String + hostIdentifierContains: String + hostIdentifierHasPrefix: String + hostIdentifierHasSuffix: String + hostIdentifierIsNil: Boolean + hostIdentifierNotNil: Boolean + hostIdentifierEqualFold: String + hostIdentifierContainsFold: String + """host_primary_ip field predicates""" + hostPrimaryIP: String + hostPrimaryIPNEQ: String + hostPrimaryIPIn: [String!] + hostPrimaryIPNotIn: [String!] + hostPrimaryIPGT: String + hostPrimaryIPGTE: String + hostPrimaryIPLT: String + hostPrimaryIPLTE: String + hostPrimaryIPContains: String + hostPrimaryIPHasPrefix: String + hostPrimaryIPHasSuffix: String + hostPrimaryIPIsNil: Boolean + hostPrimaryIPNotNil: Boolean + hostPrimaryIPEqualFold: String + hostPrimaryIPContainsFold: String + """host_platform field predicates""" + hostPlatform: BeaconHostPlatform + hostPlatformNEQ: BeaconHostPlatform + hostPlatformIn: [BeaconHostPlatform!] + hostPlatformNotIn: [BeaconHostPlatform!] + """last_seen_at field predicates""" + lastSeenAt: Time + lastSeenAtNEQ: Time + lastSeenAtIn: [Time!] + lastSeenAtNotIn: [Time!] + lastSeenAtGT: Time + lastSeenAtGTE: Time + lastSeenAtLT: Time + lastSeenAtLTE: Time + lastSeenAtIsNil: Boolean + lastSeenAtNotNil: Boolean + """tags edge predicates""" + hasTags: Boolean + hasTagsWith: [TagWhereInput!] + """tasks edge predicates""" + hasTasks: Boolean + hasTasksWith: [TaskWhereInput!] +} +""" +CreateQuestInput is used for create Quest object. +Input was generated by ent. +""" +input CreateQuestInput { + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tomeID: ID! } @@ -25,7 +215,7 @@ input CreateTagInput { name: String! """Describes the type of tag this is""" kind: TagKind! - sessionIDs: [ID!] + beaconIDs: [ID!] } """ CreateTomeInput is used for create Tome object. @@ -147,42 +337,83 @@ input FileWhereInput { hashEqualFold: String hashContainsFold: String } -type Job implements Node { +""" +An object with an ID. +Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) +""" +interface Node @goModel(model: "github.com/kcarretto/realm/tavern/ent.Noder") { + """The id of the object.""" + id: ID! +} +"""Possible directions in which to order a list of items when provided an `orderBy` argument.""" +enum OrderDirection { + """Specifies an ascending order for a given `orderBy` argument.""" + ASC + """Specifies a descending order for a given `orderBy` argument.""" + DESC +} +""" +Information about pagination in a connection. +https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo +""" +type PageInfo { + """When paginating forwards, are there more items?""" + hasNextPage: Boolean! + """When paginating backwards, are there more items?""" + hasPreviousPage: Boolean! + """When paginating backwards, the cursor to continue.""" + startCursor: Cursor + """When paginating forwards, the cursor to continue.""" + endCursor: Cursor +} +type Query { + """Fetches an object given its ID.""" + node( + """ID of the object.""" + id: ID! + ): Node + """Lookup nodes by a list of IDs.""" + nodes( + """The list of node IDs.""" + ids: [ID!]! + ): [Node]! +} +type Quest implements Node { id: ID! """Timestamp of when this ent was created""" createdAt: Time! """Timestamp of when this ent was last updated""" lastModifiedAt: Time! - """Name of the job""" + """Name of the quest""" name: String! - """Value of parameters that were specified for the job (as a JSON string).""" + """Value of parameters that were specified for the quest (as a JSON string).""" parameters: String tome: Tome! bundle: File tasks: [Task!] creator: User } -"""Ordering options for Job connections""" -input JobOrder { +"""Ordering options for Quest connections""" +input QuestOrder { """The ordering direction.""" direction: OrderDirection! = ASC - """The field by which to order Jobs.""" - field: JobOrderField! + """The field by which to order Quests.""" + field: QuestOrderField! } -"""Properties by which Job connections can be ordered.""" -enum JobOrderField { +"""Properties by which Quest connections can be ordered.""" +enum QuestOrderField { CREATED_AT LAST_MODIFIED_AT NAME } """ -JobWhereInput is used for filtering Job objects. +QuestWhereInput is used for filtering Quest objects. Input was generated by ent. """ -input JobWhereInput { - not: JobWhereInput - and: [JobWhereInput!] - or: [JobWhereInput!] +input QuestWhereInput { + not: QuestWhereInput + and: [QuestWhereInput!] + or: [QuestWhereInput!] """id field predicates""" id: ID idNEQ: ID @@ -253,244 +484,13 @@ input JobWhereInput { hasCreator: Boolean hasCreatorWith: [UserWhereInput!] } -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node @goModel(model: "github.com/kcarretto/realm/tavern/ent.Noder") { - """The id of the object.""" - id: ID! -} -"""Possible directions in which to order a list of items when provided an `orderBy` argument.""" -enum OrderDirection { - """Specifies an ascending order for a given `orderBy` argument.""" - ASC - """Specifies a descending order for a given `orderBy` argument.""" - DESC -} -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """When paginating forwards, are there more items?""" - hasNextPage: Boolean! - """When paginating backwards, are there more items?""" - hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" - startCursor: Cursor - """When paginating forwards, the cursor to continue.""" - endCursor: Cursor -} -type Query { - """Fetches an object given its ID.""" - node( - """ID of the object.""" - id: ID! - ): Node - """Lookup nodes by a list of IDs.""" - nodes( - """The list of node IDs.""" - ids: [ID!]! - ): [Node]! -} -type Session implements Node { - id: ID! - """A human readable identifier for the session.""" - name: String! - """The identity the session is authenticated as (e.g. 'root')""" - principal: String - """The hostname of the system the session is running on.""" - hostname: String - """Unique identifier for the session. Unique to each instance of the session.""" - identifier: String! - """Identifies the agent that the session is running as (e.g. 'imix').""" - agentIdentifier: String - """Unique identifier for the host the session is running on.""" - hostIdentifier: String - """Primary interface IP address reported by the agent.""" - hostPrimaryIP: String - """Platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! - """Timestamp of when a task was last claimed or updated for a target""" - lastSeenAt: Time - tags: [Tag!] - tasks: [Task!] -} -"""SessionHostPlatform is enum for the field host_platform""" -enum SessionHostPlatform @goModel(model: "github.com/kcarretto/realm/tavern/ent/session.HostPlatform") { - Windows - Linux - MacOS - BSD - Unknown -} -"""Ordering options for Session connections""" -input SessionOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Sessions.""" - field: SessionOrderField! -} -"""Properties by which Session connections can be ordered.""" -enum SessionOrderField { - LAST_SEEN_AT -} -""" -SessionWhereInput is used for filtering Session objects. -Input was generated by ent. -""" -input SessionWhereInput { - not: SessionWhereInput - and: [SessionWhereInput!] - or: [SessionWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """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 - principalIsNil: Boolean - principalNotNil: Boolean - principalEqualFold: String - principalContainsFold: String - """hostname field predicates""" - hostname: String - hostnameNEQ: String - hostnameIn: [String!] - hostnameNotIn: [String!] - hostnameGT: String - hostnameGTE: String - hostnameLT: String - hostnameLTE: String - hostnameContains: String - hostnameHasPrefix: String - hostnameHasSuffix: String - hostnameIsNil: Boolean - hostnameNotNil: Boolean - hostnameEqualFold: String - hostnameContainsFold: String - """identifier field predicates""" - identifier: String - identifierNEQ: String - identifierIn: [String!] - identifierNotIn: [String!] - identifierGT: String - identifierGTE: String - identifierLT: String - identifierLTE: String - identifierContains: String - identifierHasPrefix: String - identifierHasSuffix: String - identifierEqualFold: String - identifierContainsFold: String - """agent_identifier field predicates""" - agentIdentifier: String - agentIdentifierNEQ: String - agentIdentifierIn: [String!] - agentIdentifierNotIn: [String!] - agentIdentifierGT: String - agentIdentifierGTE: String - agentIdentifierLT: String - agentIdentifierLTE: String - agentIdentifierContains: String - agentIdentifierHasPrefix: String - agentIdentifierHasSuffix: String - agentIdentifierIsNil: Boolean - agentIdentifierNotNil: Boolean - agentIdentifierEqualFold: String - agentIdentifierContainsFold: String - """host_identifier field predicates""" - hostIdentifier: String - hostIdentifierNEQ: String - hostIdentifierIn: [String!] - hostIdentifierNotIn: [String!] - hostIdentifierGT: String - hostIdentifierGTE: String - hostIdentifierLT: String - hostIdentifierLTE: String - hostIdentifierContains: String - hostIdentifierHasPrefix: String - hostIdentifierHasSuffix: String - hostIdentifierIsNil: Boolean - hostIdentifierNotNil: Boolean - hostIdentifierEqualFold: String - hostIdentifierContainsFold: String - """host_primary_ip field predicates""" - hostPrimaryIP: String - hostPrimaryIPNEQ: String - hostPrimaryIPIn: [String!] - hostPrimaryIPNotIn: [String!] - hostPrimaryIPGT: String - hostPrimaryIPGTE: String - hostPrimaryIPLT: String - hostPrimaryIPLTE: String - hostPrimaryIPContains: String - hostPrimaryIPHasPrefix: String - hostPrimaryIPHasSuffix: String - hostPrimaryIPIsNil: Boolean - hostPrimaryIPNotNil: Boolean - hostPrimaryIPEqualFold: String - hostPrimaryIPContainsFold: String - """host_platform field predicates""" - hostPlatform: SessionHostPlatform - hostPlatformNEQ: SessionHostPlatform - hostPlatformIn: [SessionHostPlatform!] - hostPlatformNotIn: [SessionHostPlatform!] - """last_seen_at field predicates""" - lastSeenAt: Time - lastSeenAtNEQ: Time - lastSeenAtIn: [Time!] - lastSeenAtNotIn: [Time!] - lastSeenAtGT: Time - lastSeenAtGTE: Time - lastSeenAtLT: Time - lastSeenAtLTE: Time - lastSeenAtIsNil: Boolean - lastSeenAtNotNil: Boolean - """tags edge predicates""" - hasTags: Boolean - hasTagsWith: [TagWhereInput!] - """tasks edge predicates""" - hasTasks: Boolean - hasTasksWith: [TaskWhereInput!] -} type Tag implements Node { id: ID! """Name of the tag""" name: String! """Describes the type of tag this is""" kind: TagKind! - sessions: [Session!] + beacons: [Beacon!] } """TagKind is enum for the field kind""" enum TagKind @goModel(model: "github.com/kcarretto/realm/tavern/ent/tag.Kind") { @@ -544,9 +544,9 @@ input TagWhereInput { kindNEQ: TagKind kindIn: [TagKind!] kindNotIn: [TagKind!] - """sessions edge predicates""" - hasSessions: Boolean - hasSessionsWith: [SessionWhereInput!] + """beacons edge predicates""" + hasBeacons: Boolean + hasBeaconsWith: [BeaconWhereInput!] } type Task implements Node { id: ID! @@ -564,8 +564,8 @@ type Task implements Node { output: String """Error, if any, produced while executing the Task""" error: String - job: Job! - session: Session! + quest: Quest! + beacon: Beacon! } """Ordering options for Task connections""" input TaskOrder { @@ -682,12 +682,12 @@ input TaskWhereInput { errorNotNil: Boolean errorEqualFold: String errorContainsFold: String - """job edge predicates""" - hasJob: Boolean - hasJobWith: [JobWhereInput!] - """session edge predicates""" - hasSession: Boolean - hasSessionWith: [SessionWhereInput!] + """quest edge predicates""" + hasQuest: Boolean + hasQuestWith: [QuestWhereInput!] + """beacon edge predicates""" + hasBeacon: Boolean + hasBeaconWith: [BeaconWhereInput!] } type Tome implements Node { id: ID! @@ -816,13 +816,13 @@ input TomeWhereInput { hasFilesWith: [FileWhereInput!] } """ -UpdateSessionInput is used for update Session object. +UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ -input UpdateSessionInput { - """A human readable identifier for the session.""" +input UpdateBeaconInput { + """A human readable identifier for the beacon.""" name: String - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String clearHostname: Boolean addTagIDs: [ID!] @@ -838,9 +838,9 @@ input UpdateTagInput { name: String """Describes the type of tag this is""" kind: TagKind - addSessionIDs: [ID!] - removeSessionIDs: [ID!] - clearSessions: Boolean + addBeaconIDs: [ID!] + removeBeaconIDs: [ID!] + clearBeacons: Boolean } """ UpdateUserInput is used for update User object. @@ -920,25 +920,25 @@ input UserWhereInput { isAdminNEQ: Boolean } input ClaimTasksInput { - """The identity the session is authenticated as (e.g. 'root')""" + """The identity the beacon is authenticated as (e.g. 'root')""" principal: String! - """The hostname of the system the session is running on.""" + """The hostname of the system the beacon is running on.""" hostname: String! """The platform the agent is operating on.""" - hostPlatform: SessionHostPlatform! + hostPlatform: BeaconHostPlatform! """The IP address of the hosts primary interface (if available).""" hostPrimaryIP: String - """Unique identifier of the session, each running instance will be different.""" - sessionIdentifier: String! + """Unique identifier of the beacon, each running instance will be different.""" + beaconIdentifier: String! - """Unique identifier of the underlying host system the session is running on.""" + """Unique identifier of the underlying host system the beacon is running on.""" hostIdentifier: String! - """Name of the agent program the session is running as (e.g. 'imix')""" + """Name of the agent program the beacon is running as (e.g. 'imix')""" agentIdentifier: String! } @@ -962,14 +962,14 @@ input SubmitTaskResultInput { error: String }type Mutation { ### - # Job + # Quest ### - createJob(sessionIDs: [ID!]!, input: CreateJobInput!): Job @requireRole(role: USER) + createQuest(beaconIDs: [ID!]!, input: CreateQuestInput!): Quest @requireRole(role: USER) ### - # Session + # Beacon ### - updateSession(sessionID: ID!, input: UpdateSessionInput!): Session! @requireRole(role: USER) + updateBeacon(beaconID: ID!, input: UpdateBeaconInput!): Beacon! @requireRole(role: USER) ### # Tag @@ -994,8 +994,8 @@ input SubmitTaskResultInput { updateUser(userID: ID!, input: UpdateUserInput!): User @requireRole(role: ADMIN) }extend type Query { files(where: FileWhereInput): [File!]! - jobs(where: JobWhereInput): [Job!]! - sessions(where: SessionWhereInput): [Session!]! + quests(where: QuestWhereInput): [Quest!]! + beacons(where: BeaconWhereInput): [Beacon!]! tags(where: TagWhereInput): [Tag!]! tomes(where: TomeWhereInput): [Tome!]! users(where: UserWhereInput): [User!]! diff --git a/tavern/internal/www/src/App.tsx b/tavern/internal/www/src/App.tsx index dbb6fa05d..0412a444f 100644 --- a/tavern/internal/www/src/App.tsx +++ b/tavern/internal/www/src/App.tsx @@ -6,10 +6,10 @@ import { import './style.css'; import { useQuery, gql } from '@apollo/client'; -import { JobList } from "./pages/job-list"; +import { QuestList } from "./pages/quest-list"; import { createBrowserRouter, RouterProvider } from "react-router-dom"; import { Home } from "./pages/home"; -import { CreateJob } from "./pages/create-job"; +import { CreateQuest } from "./pages/create-quest"; import 'react-virtualized/styles.css'; import { TagContextProvider } from "./context/TagContext"; @@ -28,15 +28,15 @@ const GET_TOMES = gql` const router = createBrowserRouter([ { path: "/", - element: , + element: , }, { - path: "/jobs", - element: , + path: "/quests", + element: , }, { - path: "/createJob", - element: , + path: "/createQuest", + element: , }, ]); diff --git a/tavern/internal/www/src/components/session-filter-bar/SessionFilterBar.tsx b/tavern/internal/www/src/components/beacon-filter-bar/BeaconFilterBar.tsx similarity index 62% rename from tavern/internal/www/src/components/session-filter-bar/SessionFilterBar.tsx rename to tavern/internal/www/src/components/beacon-filter-bar/BeaconFilterBar.tsx index a309c62ad..317d95d0a 100644 --- a/tavern/internal/www/src/components/session-filter-bar/SessionFilterBar.tsx +++ b/tavern/internal/www/src/components/beacon-filter-bar/BeaconFilterBar.tsx @@ -1,21 +1,21 @@ import React from "react"; import {Heading} from "@chakra-ui/react"; import Select, { createFilter } from "react-select" -import { SessionType, TomeTag } from "../../utils/consts"; +import { BeaconType, TomeTag } from "../../utils/consts"; type Props = { setFiltersSelected: (arg1: any) => void; - sessions: Array; + beacons: Array; groups: Array; services: Array; } -export const SessionFilterBar = (props: Props) => { - const {setFiltersSelected, sessions, groups, services} = props; +export const BeaconFilterBar = (props: Props) => { + const {setFiltersSelected, beacons, groups, services} = props; - const getFormattedOptions = (sessions: Array, groups: Array, services: Array) => { + const getFormattedOptions = (beacons: Array, groups: Array, services: Array) => { return [ - { - label: "Service", + { + label: "Service", options: services.map(function(service: TomeTag){ return { ...service, @@ -24,8 +24,8 @@ export const SessionFilterBar = (props: Props) => { kind: service?.kind }}) }, - { - label: "Group", + { + label: "Group", options: groups.map(function(group: TomeTag){ return { ...group, @@ -35,14 +35,14 @@ export const SessionFilterBar = (props: Props) => { }; }) }, - { - label: "Session", - options: sessions.map(function(session: SessionType){ + { + label: "Beacon", + options: beacons.map(function(beacon: BeaconType){ return { - ...session, - value: session?.id, - label: session?.name, - kind: "session" + ...beacon, + value: beacon?.id, + label: beacon?.name, + kind: "beacon" }; }) }, @@ -51,17 +51,17 @@ export const SessionFilterBar = (props: Props) => { return (
          - Filter by service, group, and session + Filter by service, group, and beacon