-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #391.
- Loading branch information
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
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,33 @@ | ||
# routeros_ip_services (Data Source) | ||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `filter` (Map of String) Additional request filtering options. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `services` (List of Object) (see [below for nested schema](#nestedatt--services)) | ||
|
||
<a id="nestedatt--services"></a> | ||
### Nested Schema for `services` | ||
|
||
Read-Only: | ||
|
||
- `address` (String) | ||
- `certificate` (String) | ||
- `disabled` (Boolean) | ||
- `id` (String) | ||
- `invalid` (String) | ||
- `name` (String) | ||
- `port` (Number) | ||
- `tls_version` (String) | ||
- `vrf` (String) | ||
|
||
|
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,76 @@ | ||
package routeros | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func DatasourceIPServices() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: datasourceIPServicesRead, | ||
Schema: map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/ip/service"), | ||
MetaId: PropId(Id), | ||
|
||
KeyFilter: PropFilterRw, | ||
"services": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"address": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"certificate": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"disabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
}, | ||
"invalid": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"port": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
"tls_version": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"vrf": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func datasourceIPServicesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
s := DatasourceIPServices().Schema | ||
path := s[MetaResourcePath].Default.(string) | ||
|
||
res, err := ReadItemsFiltered(buildReadFilter(d.Get(KeyFilter).(map[string]interface{})), path, m.(Client)) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
return MikrotikResourceDataToTerraformDatasource(res, "services", s, d) | ||
} |
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