From ff0a9b0312556a1a9215c47b451cbf46c95db378 Mon Sep 17 00:00:00 2001 From: Michael Dokolin Date: Sun, 25 Feb 2024 08:49:13 +0100 Subject: [PATCH] feat: Add `http` scheme support for the REST API --- README.md | 2 +- docs/index.md | 1 + routeros/mikrotik_client.go | 1 + routeros/provider.go | 3 ++- templates/index.md.tmpl | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b275102..d03a9d90 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ terraform { } provider "routeros" { - hosturl = "(https|api|apis)://my.router.local[:port]" + hosturl = "(http|https|api|apis)://my.router.local[:port]" username = "my_username" password = "my_super_secret_password" } diff --git a/docs/index.md b/docs/index.md index 21f9143d..b75b7795 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,6 +44,7 @@ resource "routeros_interface_gre" "gre_hq" { ### Required - `hosturl` (String) URL of the ROS router. Include including the scheme: + - `http` new REST API - `https` new REST API with TLS/SSL - `api` old API without TLS/SSL on port 8728 - `apis` old API with TLS/SSL 8729 diff --git a/routeros/mikrotik_client.go b/routeros/mikrotik_client.go index e9b83071..1f2b82f9 100644 --- a/routeros/mikrotik_client.go +++ b/routeros/mikrotik_client.go @@ -86,6 +86,7 @@ func NewClient(ctx context.Context, d *schema.ResourceData) (interface{}, diag.D // Parse URL. switch routerUrl.Scheme { + case "http": case "https": case "apis": routerUrl.Scheme = "" diff --git a/routeros/provider.go b/routeros/provider.go index 3c796238..fef227a2 100644 --- a/routeros/provider.go +++ b/routeros/provider.go @@ -25,7 +25,8 @@ func Provider() *schema.Provider { * API: api[s]://host[:port] * api://router.local * apis://router.local:8729 - * REST: https://host + * REST: http[s]://host + * http://router.local * https://router.local * router.local * 127.0.0.1 diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 8f15ade6..836ae7c0 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -22,6 +22,7 @@ To get started with the provider, you first need to enable the REST API on your ### Required - `hosturl` (String) URL of the ROS router. Include including the scheme: + - `http` new REST API - `https` new REST API with TLS/SSL - `api` old API without TLS/SSL on port 8728 - `apis` old API with TLS/SSL 8729