Commit Graph

9 Commits

Author SHA1 Message Date
Florian Beisel 565f920b10
integrates Dynamic ENUM Metadata within Rules
Summary:
This commit revolutionizes our approach to handling ENUM metadata for
rule input structures by embedding this metadata directly within each
rule's definition. By leveraging the `EnumProvider` interface and
utilizing reflection, we've created a system where rules self-describe
their ENUM fields, enhancing the API's flexibility and maintainability.

The `GetRuleStruct` API endpoint is now capable of dynamically generating
responses that include both the input structure and ENUM options, directly
derived from the rule definitions themselves.

Key Changes:
- **Introduced `EnumProvider` Interface**:
Allows rule structs to define their own ENUM options, centralizing this
information within the rule implementations.

- **Enhanced Rule Descriptors**:
Rule descriptors are streamlined to focus on factory methods and input
struct types, with ENUM metadata being provided by the rules themselves
through the `EnumProvider` interface.

- **Dynamic ENUM Metadata Retrieval**:
The `GetRuleStruct` function dynamically extracts ENUM metadata from
rules that implement the `EnumProvider`, ensuring the API response
includes relevant ENUM options for frontend UI generation.

- **API Response Enhancement**:
Adjusted the API to provide a response that includes the rule's input
structure, possible ENUM values, and the rule instance representation,
all derived dynamically to support extensible and maintainable rule
definitions.
2024-02-06 21:05:44 +01:00
Florian Beisel 71ea9cac18
🎨 add helper functions and general cleanup 2024-01-24 11:04:43 +01:00
Florian Beisel 1669a65512
Implement server.go as a more complete example
This change implements the category / rule Server which will showcase
storig arbirtray alongside the hostname which are not part of hostname
generation.
2024-01-21 16:20:21 +01:00
Florian Beisel 600fb0e997
🏗️ Change notebook.go to use new interface 2024-01-21 16:19:42 +01:00
Florian Beisel f4b6197728
🏗️ Move calling Generate function to rules
This change moves the responsibility of calling the HostnameRule.Generate
function to the corresponding HostnameRule.{Insert,Update} functions
which will allow autonomy especially for the update functions on when
a hostname needs to be regenerated.
2024-01-21 16:00:33 +01:00
Florian Beisel a4748d7619
♻️ Rework rules registration
This commit adds a rule registry as a central place to register new
rules. It will expose a Description and a factory to create a rule
object.
2024-01-21 14:45:58 +01:00
Florian Beisel f0118ab8ea
🐛 Use OldHostname when querying the Database
In BaseRule.baseUpdate our goal is to check if a hostname exists before
trying to rename that hostname into something else. This patch fixes an
error where the newly generated Hostname was used to check for the
existence of the old hostname.
2024-01-18 00:11:39 +01:00
Florian Beisel 607682884c
📝 Create missing models for API documentation 2024-01-18 00:09:26 +01:00
Florian Beisel b58430af9a
Initial commit 2024-01-17 18:05:55 +01:00