-
Notifications
You must be signed in to change notification settings - Fork 63
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 user profile resource
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
examples/resources/routeros_user_manager_user_profile/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/user-profile get [print show-ids]] | ||
terraform import routeros_user_manager_user_profile.test '*1' |
12 changes: 12 additions & 0 deletions
12
examples/resources/routeros_user_manager_user_profile/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,12 @@ | ||
resource "routeros_user_manager_profile" "test" { | ||
name = "test" | ||
} | ||
|
||
resource "routeros_user_manager_user" "test" { | ||
name = "test" | ||
} | ||
|
||
resource "routeros_user_manager_user_profile" "test" { | ||
profile = routeros_user_manager_profile.test.name | ||
user = routeros_user_manager_user.test.name | ||
} |
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,48 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
{ | ||
".id": "*1", | ||
"end-time": "unlimited", | ||
"profile": "test", | ||
"state": "running", | ||
"user": "test" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/User+Manager#UserManager-UserProfiles | ||
func ResourceUserManagerUserProfile() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/user-manager/user-profile"), | ||
MetaId: PropId(Id), | ||
MetaSkipFields: PropSkipFields(`"end_time","state"`), | ||
|
||
"profile": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Name of the profile to assign to the user.", | ||
}, | ||
"user": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Name of the user to use the specified profile.", | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultCreate(resSchema), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultUpdate(resSchema), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |