-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for wpaeap and radius profiles
Fixes #26
- Loading branch information
Showing
5 changed files
with
123 additions
and
2 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,45 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataRADIUSProfile() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: ` | ||
unifi_radius_profile data source can be used to retrieve the ID for a RADIUS profile by name. | ||
`, | ||
|
||
Read: dataRADIUSProfileRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "Default", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataRADIUSProfileRead(d *schema.ResourceData, meta interface{}) error { | ||
c := meta.(*client) | ||
|
||
name := d.Get("name").(string) | ||
|
||
profiles, err := c.c.ListRADIUSProfile(context.TODO(), c.site) | ||
if err != nil { | ||
return err | ||
} | ||
for _, g := range profiles { | ||
if g.Name == name { | ||
d.SetId(g.ID) | ||
return nil | ||
} | ||
} | ||
|
||
return fmt.Errorf("RADIUS profile not found with name %s", 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
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