Skip to content

Commit 31f9c50

Browse files
committedMar 17, 2025··
feat(tool): Add /tool/mac-server/ping resource
1 parent eccc99f commit 31f9c50

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-0
lines changed
 
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# routeros_tool_mac_server_ping (Resource)
2+
3+
4+
## Example Usage
5+
```terraform
6+
resource "routeros_tool_mac_server_ping" "test" {
7+
enabled = false
8+
}
9+
```
10+
11+
<!-- schema generated by tfplugindocs -->
12+
## Schema
13+
14+
### Optional
15+
16+
- `enabled` (Boolean) Whether to enable the MAC Ping server.
17+
18+
### Read-Only
19+
20+
- `id` (String) The ID of this resource.
21+
22+
## Import
23+
Import is supported using the following syntax:
24+
```shell
25+
terraform import routeros_tool_mac_server_ping.test .
26+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import routeros_tool_mac_server_ping.test .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resource "routeros_tool_mac_server_ping" "test" {
2+
enabled = false
3+
}

‎routeros/provider.go

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ func Provider() *schema.Provider {
326326
"routeros_tool_email": ResourceToolEmail(),
327327
"routeros_tool_mac_server": ResourceToolMacServer(),
328328
"routeros_tool_mac_server_winbox": ResourceToolMacServerWinBox(),
329+
"routeros_tool_mac_server_ping": ResourceToolMacServerPing(),
329330
"routeros_tool_netwatch": ResourceToolNetwatch(),
330331
"routeros_tool_sniffer": ResourceToolSniffer(),
331332

‎routeros/resource_tool_mac_server.go

+23
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,26 @@ func ResourceToolMacServerWinBox() *schema.Resource {
6363
Schema: resSchema,
6464
}
6565
}
66+
67+
// https://help.mikrotik.com/docs/spaces/ROS/pages/98795539/MAC+server#MACserver-MACPingServer
68+
func ResourceToolMacServerPing() *schema.Resource {
69+
resSchema := map[string]*schema.Schema{
70+
MetaResourcePath: PropResourcePath("/tool/mac-server/ping"),
71+
MetaId: PropId(Id),
72+
73+
KeyEnabled: PropEnabled("Whether to enable the MAC Ping server."),
74+
}
75+
76+
return &schema.Resource{
77+
CreateContext: DefaultSystemCreate(resSchema),
78+
ReadContext: DefaultSystemRead(resSchema),
79+
UpdateContext: DefaultSystemUpdate(resSchema),
80+
DeleteContext: DefaultSystemDelete(resSchema),
81+
82+
Importer: &schema.ResourceImporter{
83+
StateContext: schema.ImportStatePassthroughContext,
84+
},
85+
86+
Schema: resSchema,
87+
}
88+
}

‎routeros/resource_tool_mac_server_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,37 @@ func TestAccToolsMacServerWinBoxTest_basic(t *testing.T) {
6969
}
7070
}
7171

72+
const testToolsMacServerPing = "routeros_tool_mac_server_ping.test"
73+
74+
func TestAccToolsMacServerPingTest_basic(t *testing.T) {
75+
for _, name := range testNames {
76+
t.Run(name, func(t *testing.T) {
77+
resource.Test(t, resource.TestCase{
78+
PreCheck: func() {
79+
testAccPreCheck(t)
80+
testSetTransportEnv(t, name)
81+
},
82+
ProviderFactories: testAccProviderFactories,
83+
Steps: []resource.TestStep{
84+
{
85+
Config: testAccToolsMacServerPingConfig(true),
86+
Check: resource.ComposeTestCheckFunc(
87+
testResourcePrimaryInstanceId(testToolsMacServerPing),
88+
resource.TestCheckResourceAttr(testToolsMacServerPing, "enabled", "yes"),
89+
),
90+
},
91+
{
92+
Config: testAccToolsMacServerPingConfig(false),
93+
Check: resource.ComposeTestCheckFunc(
94+
resource.TestCheckResourceAttr(testToolsMacServerPing, "enabled", "no"),
95+
),
96+
},
97+
},
98+
})
99+
})
100+
}
101+
}
102+
72103
func testAccToolsMacServerConfig(acl string) string {
73104
return fmt.Sprintf(`%v
74105
@@ -86,3 +117,12 @@ resource "routeros_tool_mac_server_winbox" "test" {
86117
}
87118
`, providerConfig, acl)
88119
}
120+
121+
func testAccToolsMacServerPingConfig(enabled bool) string {
122+
return fmt.Sprintf(`%v
123+
124+
resource "routeros_tool_mac_server_ping" "test" {
125+
enabled = %v
126+
}
127+
`, providerConfig, enabled)
128+
}

0 commit comments

Comments
 (0)
Please sign in to comment.