Skip to content

Commit

Permalink
[minor_change] Allow dn based filtering for aci_client_end_point data…
Browse files Browse the repository at this point in the history
…source
  • Loading branch information
akinross authored and lhercot committed Jun 25, 2024
1 parent 5f5cc63 commit eae7e6a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
17 changes: 16 additions & 1 deletion aci/data_source_aci_fvcep.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ func dataSourceAciClientEndPoint() *schema.Resource {
SchemaVersion: 1,

Schema: AppendAttrSchemas(map[string]*schema.Schema{
"name": &schema.Schema{Type: schema.TypeString,
"name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
Expand All @@ -43,6 +44,12 @@ func dataSourceAciClientEndPoint() *schema.Resource {
Computed: true,
},

"filter_dn": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"fvcep_objects": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -362,6 +369,14 @@ func dataSourceAciClientEndPointRead(d *schema.ResourceData, m interface{}) erro
}
}

if filterDn, ok := d.GetOk("filter_dn"); ok {
if queryString != "" {
queryString = fmt.Sprintf("%s,wcard(fvCEp.dn, \"%s\")", queryString, filterDn.(string))
} else {
queryString = fmt.Sprintf("wcard(fvCEp.dn, \"%s*\")", filterDn.(string))
}
}

objects, dns, err := getRemoteClientEndPoint(aciClient, queryString, allowEmptyResult)
if err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions docs/data-sources/client_end_point.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ data "aci_client_end_point" "check" {
vlan = "5"
allow_empty_result = true
}
data "aci_client_end_point" "check_on_epg_dn" {
filter_dn = "uni/tn-{tenant_name}/ap-{ap_name}/epg-{epg_name}"
}
data "aci_client_end_point" "check_on_epg_dn_as_reference" {
filter_dn = data.aci_application_epg.application_epg.id
}
```

## Argument Reference
Expand All @@ -39,6 +47,7 @@ data "aci_client_end_point" "check" {
- `mac` - (Optional) MAC address of the Client End Point object.
- `ip` - (Optional) IP address of the Client End Point object.
- `vlan` - (Optional) VLAN of the Client End Point object.
- `filter_dn` - (Optional) Filter based on matching DN (Distinguished Name) of parents.
- `allow_empty_result` - (Optional) Empty return instead of error when client is not found. Default value is "false".

## Attribute Reference
Expand Down
32 changes: 32 additions & 0 deletions examples/aci_client_end_point/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,36 @@ data "aci_client_end_point" "this" {

output "mac_endpoints" {
value = data.aci_client_end_point.this.fvcep_objects
}

data "aci_tenant" "tenant" {
name = "tenant_name"
}

data "aci_application_profile" "application_profile" {
tenant_dn = data.aci_tenant.tenant.id
name = "application_name"
}

data "aci_application_epg" "application_epg" {
application_profile_dn = data.aci_application_profile.application_profile.id
name = "epg_name"
}

# Filter based on Tenants

data "aci_client_end_point" "end_points" {
filter_dn = data.aci_tenant.tenant.id
}

# Filter based on Application Profiles

data "aci_client_end_point" "end_points" {
filter_dn = data.aci_application_profile.application_profile.id
}

# Filter based on EPGs

data "aci_client_end_point" "end_points" {
filter_dn = data.aci_application_epg.application_epg.id
}
9 changes: 9 additions & 0 deletions legacy-docs/docs/d/client_end_point.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ data "aci_client_end_point" "check" {
vlan = "5"
allow_empty_result = true
}
data "aci_client_end_point" "check_on_epg_dn" {
filter_dn = "uni/tn-{tenant_name}/ap-{ap_name}/epg-{epg_name}"
}
data "aci_client_end_point" "check_on_epg_dn_as_reference" {
filter_dn = data.aci_application_epg.application_epg.id
}
```

## Argument Reference
Expand All @@ -39,6 +47,7 @@ data "aci_client_end_point" "check" {
- `mac` - (Optional) MAC address of the Client End Point object.
- `ip` - (Optional) IP address of the Client End Point object.
- `vlan` - (Optional) VLAN of the Client End Point object.
- `filter_dn` - (Optional) Filter based on matching DN (Distinguished Name) of parents.
- `allow_empty_result` - (Optional) Empty return instead of error when client is not found. Default value is "false".

## Attribute Reference
Expand Down

0 comments on commit eae7e6a

Please sign in to comment.