Skip to content

Commit 48e8502

Browse files
rsharmaInfobloxChaithra001
authored andcommitted
NPA-1227: Resource and DataSource for RPZ PTR Record (infobloxopen#278)
* NPA-1227: added resource and data source for rpz ptr record * NPA-1227: added fix for sending rp_zone in update req because of wapi behavior * NPA-1227: removed duplicate parent zone func * NPA-1227: fixed some markdown desc comments and cosmetic changes * NPA-1227: used exactly one of validator instead of validate config for name, ipv4 and ipv6 presence * NPA-1227: added base func for custom view
1 parent 86dac8b commit 48e8502

File tree

15 files changed

+1866
-11
lines changed

15 files changed

+1866
-11
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "nios_rpz_record_ptr Data Source - nios"
4+
subcategory: "RPZ"
5+
description: |-
6+
Retrieves information about existing RPZ PTR Records.
7+
---
8+
9+
# nios_rpz_record_ptr (Data Source)
10+
11+
Retrieves information about existing RPZ PTR Records.
12+
13+
## Example Usage
14+
15+
```terraform
16+
// Retrieve a specific RPZ PTR record by filters
17+
data "nios_rpz_record_ptr" "get_record_using_filters" {
18+
filters = {
19+
ptrdname = "record1.rpz.example.com"
20+
}
21+
}
22+
23+
// Retrieve specific RPZ PTR records using Extensible Attributes
24+
data "nios_rpz_record_ptr" "get_record_using_extensible_attributes" {
25+
extattrfilters = {
26+
Site = "location-1"
27+
}
28+
}
29+
30+
// Retrieve all RPZ PTR records
31+
data "nios_rpz_record_ptr" "get_all_rpz_ptr_records" {}
32+
```
33+
34+
<!-- schema generated by tfplugindocs -->
35+
## Schema
36+
37+
### Optional
38+
39+
- `extattrfilters` (Map of String) External Attribute Filters are used to return a more specific list of results by filtering on external attributes. If you specify multiple filters, the results returned will have only resources that match all the specified filters.
40+
- `filters` (Map of String) Filter are used to return a more specific list of results. Filters can be used to match resources by specific attributes, e.g. name. If you specify multiple filters, the results returned will have only resources that match all the specified filters.
41+
- `max_results` (Number) Maximum number of objects to be returned. Defaults to 1000.
42+
- `paging` (Number) Enable (1) or disable (0) paging for the data source query. When enabled, the system retrieves results in pages, allowing efficient handling of large result sets. Paging is enabled by default.
43+
44+
### Read-Only
45+
46+
- `result` (Attributes List) (see [below for nested schema](#nestedatt--result))
47+
48+
<a id="nestedatt--result"></a>
49+
### Nested Schema for `result`
50+
51+
Required:
52+
53+
- `ptrdname` (String) The domain name of the RPZ Substitute (PTR Record) Rule object in FQDN format.
54+
- `rp_zone` (String) The name of a response policy zone in which the record resides.
55+
56+
Optional:
57+
58+
- `comment` (String) The comment for the record; maximum 256 characters.
59+
- `disable` (Boolean) Determines if the record is disabled or not. False means that the record is enabled.
60+
- `extattrs` (Map of String) Extensible attributes associated with the object. For valid values for extensible attributes, see {extattrs:values}.
61+
- `ipv4addr` (String) The IPv4 Address of the substitute rule.
62+
- `ipv6addr` (String) The IPv6 Address of the substitute rule.
63+
- `name` (String) The name of the RPZ Substitute (PTR Record) Rule object in FQDN format.
64+
- `ttl` (Number) The Time To Live (TTL) value for record. A 32-bit unsigned integer that represents the duration, in seconds, for which the record is valid (cached). Zero indicates that the record should not be cached.
65+
- `use_ttl` (Boolean) Use flag for: ttl
66+
- `view` (String) The name of the DNS View in which the record resides. Example: "external".
67+
68+
Read-Only:
69+
70+
- `extattrs_all` (Map of String) Extensible attributes associated with the object, including default attributes.
71+
- `ref` (String) The reference to the object.
72+
- `zone` (String) The name of the zone in which the record resides. Example: "zone.com". If a view is not specified when searching by zone, the default view is used.

docs/resources/rpz_record_a.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "nios_rpz_record_a Resource - nios"
44
subcategory: "RPZ"
55
description: |-
6-
Manages a RPZ A record.
6+
Manages an RPZ A record.
77
---
88

99
# nios_rpz_record_a (Resource)
1010

11-
Manages a RPZ A record.
11+
Manages an RPZ A record.
1212

1313
## Example Usage
1414

docs/resources/rpz_record_ptr.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "nios_rpz_record_ptr Resource - nios"
4+
subcategory: "RPZ"
5+
description: |-
6+
Manages an RPZ PTR record.
7+
---
8+
9+
# nios_rpz_record_ptr (Resource)
10+
11+
Manages an RPZ PTR record.
12+
13+
## Example Usage
14+
15+
```terraform
16+
// Create Parent RP Zone
17+
resource "nios_dns_zone_rp" "parent_zone" {
18+
fqdn = "rpz.example.com"
19+
}
20+
21+
// Create Record RPZ PTR with Basic Fields
22+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr" {
23+
ptrdname = "record1.${nios_dns_zone_rp.parent_zone.fqdn}"
24+
ipv4addr = "10.10.0.1"
25+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
26+
}
27+
28+
// Create Record RPZ PTR with Additional Fields
29+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr_with_additional_fields" {
30+
ptrdname = "record2.${nios_dns_zone_rp.parent_zone.fqdn}"
31+
ipv4addr = "10.10.0.2"
32+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
33+
view = "default"
34+
use_ttl = true
35+
ttl = 10
36+
comment = "Example RPZ PTR record"
37+
extattrs = {
38+
Site = "location-1"
39+
}
40+
}
41+
42+
// Create Record RPZ PTR with Name
43+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr_with_name" {
44+
ptrdname = "record3.${nios_dns_zone_rp.parent_zone.fqdn}"
45+
name = "3.0.10.10.in-addr.arpa.${nios_dns_zone_rp.parent_zone.fqdn}"
46+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
47+
view = "default"
48+
extattrs = {
49+
Site = "location-1"
50+
}
51+
}
52+
53+
// Create Record RPZ PTR with IPv6 Address
54+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr_with_ipv6addr" {
55+
ptrdname = "record4.${nios_dns_zone_rp.parent_zone.fqdn}"
56+
ipv6addr = "2002:1f93::12:1"
57+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
58+
view = "default"
59+
extattrs = {
60+
Site = "location-1"
61+
}
62+
}
63+
```
64+
65+
<!-- schema generated by tfplugindocs -->
66+
## Schema
67+
68+
### Required
69+
70+
- `ptrdname` (String) The domain name of the RPZ Substitute (PTR Record) Rule object in FQDN format.
71+
- `rp_zone` (String) The name of a response policy zone in which the record resides.
72+
73+
### Optional
74+
75+
- `comment` (String) The comment for the record; maximum 256 characters.
76+
- `disable` (Boolean) Determines if the record is disabled or not. False means that the record is enabled.
77+
- `extattrs` (Map of String) Extensible attributes associated with the object. For valid values for extensible attributes, see {extattrs:values}.
78+
- `ipv4addr` (String) The IPv4 Address of the substitute rule.
79+
- `ipv6addr` (String) The IPv6 Address of the substitute rule.
80+
- `name` (String) The name of the RPZ Substitute (PTR Record) Rule object in FQDN format.
81+
- `ttl` (Number) The Time To Live (TTL) value for record. A 32-bit unsigned integer that represents the duration, in seconds, for which the record is valid (cached). Zero indicates that the record should not be cached.
82+
- `use_ttl` (Boolean) Use flag for: ttl
83+
- `view` (String) The name of the DNS View in which the record resides. Example: "external".
84+
85+
### Read-Only
86+
87+
- `extattrs_all` (Map of String) Extensible attributes associated with the object, including default attributes.
88+
- `ref` (String) The reference to the object.
89+
- `zone` (String) The name of the zone in which the record resides. Example: "zone.com". If a view is not specified when searching by zone, the default view is used.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Retrieve a specific RPZ PTR record by filters
2+
data "nios_rpz_record_ptr" "get_record_using_filters" {
3+
filters = {
4+
ptrdname = "record1.rpz.example.com"
5+
}
6+
}
7+
8+
// Retrieve specific RPZ PTR records using Extensible Attributes
9+
data "nios_rpz_record_ptr" "get_record_using_extensible_attributes" {
10+
extattrfilters = {
11+
Site = "location-1"
12+
}
13+
}
14+
15+
// Retrieve all RPZ PTR records
16+
data "nios_rpz_record_ptr" "get_all_rpz_ptr_records" {}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Create Parent RP Zone
2+
resource "nios_dns_zone_rp" "parent_zone" {
3+
fqdn = "rpz.example.com"
4+
}
5+
6+
// Create Record RPZ PTR with Basic Fields
7+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr" {
8+
ptrdname = "record1.${nios_dns_zone_rp.parent_zone.fqdn}"
9+
ipv4addr = "10.10.0.1"
10+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
11+
}
12+
13+
// Create Record RPZ PTR with Additional Fields
14+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr_with_additional_fields" {
15+
ptrdname = "record2.${nios_dns_zone_rp.parent_zone.fqdn}"
16+
ipv4addr = "10.10.0.2"
17+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
18+
view = "default"
19+
use_ttl = true
20+
ttl = 10
21+
comment = "Example RPZ PTR record"
22+
extattrs = {
23+
Site = "location-1"
24+
}
25+
}
26+
27+
// Create Record RPZ PTR with Name
28+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr_with_name" {
29+
ptrdname = "record3.${nios_dns_zone_rp.parent_zone.fqdn}"
30+
name = "3.0.10.10.in-addr.arpa.${nios_dns_zone_rp.parent_zone.fqdn}"
31+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
32+
view = "default"
33+
extattrs = {
34+
Site = "location-1"
35+
}
36+
}
37+
38+
// Create Record RPZ PTR with IPv6 Address
39+
resource "nios_rpz_record_ptr" "create_record_rpz_ptr_with_ipv6addr" {
40+
ptrdname = "record4.${nios_dns_zone_rp.parent_zone.fqdn}"
41+
ipv6addr = "2002:1f93::12:1"
42+
rp_zone = nios_dns_zone_rp.parent_zone.fqdn
43+
view = "default"
44+
extattrs = {
45+
Site = "location-1"
46+
}
47+
}

internal/provider/provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (p *NIOSProvider) Resources(_ context.Context) []func() resource.Resource {
198198
notification.NewNotificationRestEndpointResource,
199199

200200
rpz.NewRecordRpzAResource,
201-
201+
rpz.NewRecordRpzPtrResource,
202202
rpz.NewRecordRpzMxResource,
203203
}
204204
}
@@ -304,7 +304,7 @@ func (p *NIOSProvider) DataSources(ctx context.Context) []func() datasource.Data
304304
notification.NewNotificationRestEndpointDataSource,
305305

306306
rpz.NewRecordRpzADataSource,
307-
307+
rpz.NewRecordRpzPtrDataSource,
308308
rpz.NewRecordRpzMxDataSource,
309309
}
310310
}

0 commit comments

Comments
 (0)