From 5662c875ccbb99af3d39fb4ce2a30ad9967efe52 Mon Sep 17 00:00:00 2001 From: program-- Date: Tue, 28 May 2024 15:27:45 -0700 Subject: [PATCH] cli/api: 1.1.0 changes; / -> /health endpoint --- api/api.R | 7 ++++--- cli/main.go | 11 +++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/api/api.R b/api/api.R index e67b5f5..5c44971 100644 --- a/api/api.R +++ b/api/api.R @@ -17,9 +17,10 @@ # . #* @apiTitle Hydrofabric Subsetter -#* @apiDescription This is a sample server for a subsetting Cloud Native Hydrofabrics +#* @apiDescription This is a REST API for subsetting cloud-native hydrofabrics. #* @apiContact list(name = "hfsubsetCLI API Support", email = "jjohnson@lynker.com") #* @apiLicense list(name = "GNU General Public License (GPL-3.0)", url = "https://www.gnu.org/licenses/") +#* @apiVersion 1.1.0 logger::log_formatter(logger::formatter_glue_safe) @@ -149,9 +150,9 @@ function(req) { } #* Health Check -#* @head / +#* @head /health function(req, res) { - res$setHeader("X-HFSUBSET-API-VERSION", "1.0.0") + res$setHeader("X-HFSUBSET-API-VERSION", "1.1.0") res } diff --git a/cli/main.go b/cli/main.go index 15b2928..e9d4bd4 100644 --- a/cli/main.go +++ b/cli/main.go @@ -37,6 +37,7 @@ const USAGE string = `hfsubset - Hydrofabric Subsetter Usage: hfsubset [OPTIONS] identifiers... hfsubset (-h | --help) + hfsubset -version Examples: hfsubset -o ./divides_nexus.gpkg \ @@ -154,7 +155,7 @@ func outputFile(path string, r io.Reader) (int64, error) { } func endpointVerify(endpoint string) (string, error) { - resp, err := sendRequest("HEAD", endpoint) + resp, err := sendRequest("HEAD", endpoint+"health") if err != nil { return "", err } @@ -167,7 +168,7 @@ func endpointVerify(endpoint string) (string, error) { ver := resp.Header.Get("X-HFSUBSET-API-VERSION") if ver == "" { - ver = "0.1.0-alpha" // initial version, pre 0.1.0 + ver = "<=1.0.0" // initial version, pre 0.1.0 } return ver, nil @@ -216,10 +217,16 @@ func main() { flag.BoolVar(&debug, "debug", false, "Run in debug mode") flag.BoolVar(&verify, "verify", true, "Verify that endpoint is available") flag.BoolVar(&dryRun, "dryrun", false, "Perform a dry run, only outputting the request that will be sent") + version := flag.Bool("version", false, "Output the version") layers := flag.String("l", "divides,flowlines,network,nexus", "Comma-delimited list of layers to subset.") weights := flag.String("w", "", "Comma-delimited list of weights to generate over the subset.") flag.Parse() + if version != nil && *version { + fmt.Println("hfsubset v1.1.0") + return + } + if len(flag.Args()) == 0 { flag.Usage() return