-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add user manager profile limitation resource
- Loading branch information
Showing
4 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
examples/resources/routeros_user_manager_profile_limitation/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#The ID can be found via API or the terminal | ||
#The command for the terminal is -> :put [/user-manager/profile-limitation get [print show-ids]] | ||
terraform import routeros_user_manager_profile_limitation.weekend_night '*1' |
23 changes: 23 additions & 0 deletions
23
examples/resources/routeros_user_manager_profile_limitation/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
resource "routeros_user_manager_limitation" "test" { | ||
name = "test" | ||
download_limit = 1024 | ||
upload_limit = 1024 | ||
uptime_limit = "10d" | ||
} | ||
|
||
resource "routeros_user_manager_profile" "test" { | ||
name = "test" | ||
name_for_users = "Test" | ||
price = 0.02 | ||
} | ||
|
||
resource "routeros_user_manager_profile_limitation" "weekend_night" { | ||
limitation = routeros_user_manager_limitation.test.name | ||
profile = routeros_user_manager_profile.test.name | ||
from_time = "0s" | ||
till_time = "6h" | ||
weekdays = [ | ||
"sunday", | ||
"saturday", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*1", | ||
"from-time": "0s", | ||
"limitation": "test", | ||
"profile": "test", | ||
"till-time": "23h59m59s", | ||
"weekdays": "sunday,monday,tuesday,wednesday,thursday,friday,saturday" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/User+Manager#UserManager-ProfileLimitations | ||
func ResourceUserManagerProfileLimitation() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/user-manager/profile-limitation"), | ||
MetaId: PropId(Id), | ||
|
||
"from_time": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "0s", | ||
Description: "Time of the day when the limitation should take place.", | ||
DiffSuppressFunc: TimeEquall, | ||
}, | ||
"limitation": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The limitation name.", | ||
}, | ||
"profile": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The profile name.", | ||
}, | ||
"till_time": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "23h59m59s", | ||
Description: "Time of the day when the limitation should end.", | ||
DiffSuppressFunc: TimeEquall, | ||
}, | ||
"weekdays": { | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
ValidateFunc: validation.StringInSlice([]string{"sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"}, false), | ||
}, | ||
Description: "Days of the week when the limitation is active.", | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |