Skip to content

Commit

Permalink
feat: Add the routeros_system_led_settings resource to manage the L…
Browse files Browse the repository at this point in the history
…ED settings
  • Loading branch information
dokmic authored and vaerh committed Aug 19, 2024
1 parent 4251b6a commit 82434f8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/resources/routeros_system_led_settings/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import routeros_system_led_settings.settings .
3 changes: 3 additions & 0 deletions examples/resources/routeros_system_led_settings/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "routeros_system_led_settings" "settings" {
all_leds_off = "immediate"
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func Provider() *schema.Provider {
"routeros_certificate_scep_server": ResourceCertificateScepServer(),
"routeros_system_clock": ResourceSystemClock(),
"routeros_system_identity": ResourceSystemIdentity(),
"routeros_system_led_settings": ResourceSystemLedSettings(),
"routeros_system_logging": ResourceSystemLogging(),
"routeros_system_logging_action": ResourceSystemLoggingAction(),
"routeros_system_ntp_client": ResourceSystemNtpClient(),
Expand Down
41 changes: 41 additions & 0 deletions routeros/resource_system_led_settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package routeros

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

/*
{
"all-leds-off": "never"
}
*/

// https://help.mikrotik.com/docs/display/ROS/LEDs#LEDs-LEDSettings
func ResourceSystemLedSettings() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/system/leds/settings"),
MetaId: PropId(Id),

"all_leds_off": {
Type: schema.TypeString,
Optional: true,
Description: "An option to set when all LEDs should be turned off. Possible values: `after-1h`, `after-1min`, `immediate`, `never`.",
ValidateFunc: validation.StringInSlice([]string{"after-1h", "after-1min", "immediate", "never"}, false),
DiffSuppressFunc: AlwaysPresentNotUserProvided,
},
}

return &schema.Resource{
CreateContext: DefaultSystemCreate(resSchema),
ReadContext: DefaultSystemRead(resSchema),
UpdateContext: DefaultSystemUpdate(resSchema),
DeleteContext: DefaultSystemDelete(resSchema),

Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: resSchema,
}
}

0 comments on commit 82434f8

Please sign in to comment.