Skip to content

Commit

Permalink
feat: Add user manager advanced settings resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dokmic authored and vaerh committed Dec 2, 2023
1 parent 23761cf commit 287db08
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import routeros_user_manager_advanced.settings .
4 changes: 4 additions & 0 deletions examples/resources/routeros_user_manager_advanced/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "routeros_user_manager_advanced" "settings" {
web_private_password = "password"
web_private_username = "admin"
}
1 change: 1 addition & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func Provider() *schema.Provider {
"routeros_wireguard_keys": ResourceWireguardKeys(),

// User Manager
"routeros_user_manager_advanced": ResourceUserManagerAdvanced(),
"routeros_user_manager_attribute": ResourceUserManagerAttribute(),
"routeros_user_manager_database": ResourceUserManagerDatabase(),
"routeros_user_manager_settings": ResourceUserManagerSettings(),
Expand Down
83 changes: 83 additions & 0 deletions routeros/resource_user_manager_advanced.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package routeros

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

/*
{
"paypal-allow": "false",
"paypal-currency": "USD",
"paypal-password": "",
"paypal-signature": "",
"paypal-use-sandbox": "false",
"paypal-user": "",
"web-private-password": "",
"web-private-username": ""
}
*/

// https://help.mikrotik.com/docs/display/ROS/User+Manager#UserManager-Advanced
func ResourceUserManagerAdvanced() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/user-manager/advanced"),
MetaId: PropId(Id),

"paypal_allow": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "An option whether to enable PayPal functionality for User Manager.",
},
"paypal_currency": {
Type: schema.TypeString,
Optional: true,
Default: "USD",
Description: "The currency related to price setting in which users will be billed.",
},
"paypal_password": {
Type: schema.TypeString,
Optional: true,
Description: "The password of the PayPal API account.",
},
"paypal_signature": {
Type: schema.TypeString,
Optional: true,
Description: "The signature of the PayPal API account.",
},
"paypal_use_sandbox": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "An option whether to use PayPal's sandbox environment for testing purposes.",
},
"paypal_user": {
Type: schema.TypeString,
Optional: true,
Description: "The username of the PayPal API account.",
},
"web_private_password": {
Type: schema.TypeString,
Optional: true,
Description: "The password for accessing `/um/PRIVATE/` section over HTTP.",
},
"web_private_username": {
Type: schema.TypeString,
Optional: true,
Description: "The username for accessing `/um/PRIVATE/` section over HTTP.",
},
}

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 287db08

Please sign in to comment.