[DEV] Redesign and Create New Flexible and Simplified API #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Problem
The way that the
configuratoris currently designed is a bit cumbersome and can be confusing to use. For example, to generate a config file currently, one must have a config file andConfig file:
Then we invoke the
generatecommand:And then, if we want to run
configuratoras a service:We can use
curlor theconfiguratoras a client to generate a new config, but it isn't exactly obvious how this should work.The Proposed Solution
It would be better to simplify
configurator's setup and API to make it much easier to use. Instead of using "targets", theconfiguratorwill be path-based routing (like an FTP server) and just point to a root directory to serve files which can include any kind of file or directory. The user should be able to download files exactly like they are, download directories and archives, and render the Jinja 2 template files. This is now done using plugins rather than explicitly calling a "render" function.For example, I should be able to download a file or directory directly:
The user should also be able to upload files to the
configuratorusing an/uploadendpoint. This endpoint can optionally be protected with JWT verification if needed.The
configuratorclient will also be able to execute plugins remotely as well as download an execute plugins locally. This allows more customization when populating template variables. Additionally, templates can be populated using "profile" variables.Proposed New/revamped features:
New proposed Rest API:
This is the new proposed API served when running
configuratoras a microservice.GET
/download/{path}- download a file or directory (as archive) with optional templatingPOST
/upload- upload a file, directory, or template toconfiguratorroot pathGET
/list- show the available files, directories, and templatesPOST
/profile- create a new profile with specified dataGET
/profile- get all existing profile dataGET
/profile/{id}- get a profile by IDPOST
/profile/{id}- get profile data by IDPOST
/profile/{id}/data/{varname}- set profile variable valueDELETE
/profile/{id}/data/{varname}- remove profile variableGET
/profile/{id}/data- get all profile dataGET
/profile/{id}/data/{varname}- get a profile variable valuePOST
/profile/{id}/paths/{path}- add path to file or directory for renderingDELETE
/profile/{id}/paths/{path}- remove path to file or directory for renderingGET
/profile/{id}/paths- get all paths for specified profileGET
/plugins- list available plugins on the serverPOST
/plugins- add a new plugin to the serverDELETE
/plugins/{id}- remove a plugin by its IDOther Miscellaneous Stuff
Profiles are represented with the following struct:
New proposed example usage:
delete existing profile
configurator profile delete example
Alternatively, we can use
curlto do the same as above.Revised Plugin System
Plugins are used to fetch, create, modify, etc. data that can be used for creating new mappings provided by the service. Plugins typically live on the server and can called with requests to the
/renderendpoint. When starting the service, you must point to a directory that stores the plugins as well as any individual plugins stored elsewhere.A plugin is defined by a simple interface and must be implemented to be used with the
configurator. Each plugin returns a setting of mappings used for rendering of a Jinja 2 template.An example implementation would look like this:
Local Plugins
In additional to rendering files with remote plugins, you can also use local plugins stored on your file system. If the
-ooption is specified, the output will be saved to a file. Otherwise, the output is printed to stdout.Configuration
These are some of the configuration options in YAML for the server component:
[FEATURE] Redesign and Create new simplied APIto [DEV] Redesign and Create new simplied API[DEV] Redesign and Create new simplied APIto [DEV] Redesign and Create New Flexible and Simplied API[DEV] Redesign and Create New Flexible and Simplied APIto [DEV] Redesign and Create New Flexible and Simplified API