Skip to content

Commit bcb13be

Browse files
Update wireless profile api endpoint (#110)
1 parent ec8fd51 commit bcb13be

File tree

15 files changed

+366
-82
lines changed

15 files changed

+366
-82
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 0.1.10 (unreleased)
22

3+
- BREAKING CHANGE: Modified `wireless_profile` resource to use `/intent/api/v1/wirelessProfiles` API endpoint, this resource now only works with Catalyst Center version 2.3.7.6+
34
- Add `wireless_device_provision` resource
45
- Add `fabric_provision_device` resource and data source
56
- Add `assign_templates_to_tag` resource and data source

docs/data-sources/wireless_profile.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "catalystcenter_wireless_profile Data Source - terraform-provider-catalystcenter"
4+
subcategory: "Wireless"
5+
description: |-
6+
This data source can read the Wireless Profile.
7+
---
8+
9+
# catalystcenter_wireless_profile (Data Source)
10+
11+
This data source can read the Wireless Profile.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "catalystcenter_wireless_profile" "example" {
17+
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `id` (String) The id of the object
27+
28+
### Read-Only
29+
30+
- `ssid_details` (Attributes List) SSID Details (see [below for nested schema](#nestedatt--ssid_details))
31+
- `wireless_profile_name` (String) Wireless Network Profile Name
32+
33+
<a id="nestedatt--ssid_details"></a>
34+
### Nested Schema for `ssid_details`
35+
36+
Read-Only:
37+
38+
- `dot11be_profile_id` (String) 802.11be Profile Id. Applicable to IOS controllers with version 17.15 and higher. 802.11be Profiles if passed, should be same across all SSIDs in network profile being configured
39+
- `enable_fabric` (Boolean) True if fabric is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time
40+
- `enable_flex_connect` (Boolean) True if flex connect is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time
41+
- `interface_name` (String) Interface Name
42+
- `local_to_vlan` (Number) Local To Vlan Id
43+
- `ssid_name` (String) SSID Name
44+
- `wlan_profile_name` (String) WLAN Profile Name

docs/guides/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: |-
99

1010
## 0.1.10 (unreleased)
1111

12+
- BREAKING CHANGE: Modified `wireless_profile` resource to use `/intent/api/v1/wirelessProfiles` API endpoint, this resource now only works with Catalyst Center version 2.3.7.6+
1213
- Add `wireless_device_provision` resource
1314
- Add `fabric_provision_device` resource and data source
1415
- Add `assign_templates_to_tag` resource and data source

docs/resources/wireless_profile.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ This resource creates a wireless network profile. To associate a wireless networ
1414

1515
```terraform
1616
resource "catalystcenter_wireless_profile" "example" {
17-
name = "Wireless_Profile_1"
17+
wireless_profile_name = "Wireless_Profile_1"
1818
ssid_details = [
1919
{
20-
name = "mySSID1"
20+
ssid_name = "mySSID1"
2121
enable_fabric = true
2222
enable_flex_connect = false
2323
}
@@ -30,7 +30,7 @@ resource "catalystcenter_wireless_profile" "example" {
3030

3131
### Required
3232

33-
- `name` (String) Profile Name
33+
- `wireless_profile_name` (String) Wireless Network Profile Name
3434

3535
### Optional
3636

@@ -45,21 +45,22 @@ resource "catalystcenter_wireless_profile" "example" {
4545

4646
Required:
4747

48-
- `name` (String) Ssid Name
48+
- `ssid_name` (String) SSID Name
4949

5050
Optional:
5151

52-
- `enable_fabric` (Boolean) `true` if ssid is fabric else `false`
53-
- `enable_flex_connect` (Boolean) `true` if flex connect is enabled else `false`
52+
- `dot11be_profile_id` (String) 802.11be Profile Id. Applicable to IOS controllers with version 17.15 and higher. 802.11be Profiles if passed, should be same across all SSIDs in network profile being configured
53+
- `enable_fabric` (Boolean) True if fabric is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time
54+
- `enable_flex_connect` (Boolean) True if flex connect is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time
5455
- `interface_name` (String) Interface Name
56+
- Default value: `management`
5557
- `local_to_vlan` (Number) Local To Vlan Id
56-
- `policy_profile_name` (String) Policy Profile Name
5758
- `wlan_profile_name` (String) WLAN Profile Name
5859

5960
## Import
6061

6162
Import is supported using the following syntax:
6263

6364
```shell
64-
terraform import catalystcenter_wireless_profile.example "<id>"
65+
terraform import catalystcenter_wireless_profile.example "4b0b7a80-44c0-4bf2-bab5-fc24b4e0a17e"
6566
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "catalystcenter_wireless_profile" "example" {
2+
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
terraform import catalystcenter_wireless_profile.example "<id>"
1+
terraform import catalystcenter_wireless_profile.example "4b0b7a80-44c0-4bf2-bab5-fc24b4e0a17e"

examples/resources/catalystcenter_wireless_profile/resource.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
resource "catalystcenter_wireless_profile" "example" {
2-
name = "Wireless_Profile_1"
2+
wireless_profile_name = "Wireless_Profile_1"
33
ssid_details = [
44
{
5-
name = "mySSID1"
5+
ssid_name = "mySSID1"
66
enable_fabric = true
77
enable_flex_connect = false
88
}

gen/definitions/wireless_profile.yaml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
---
22
name: Wireless Profile
3-
rest_endpoint: /dna/intent/api/v2/wireless/profile
3+
rest_endpoint: /intent/api/v1/wirelessProfiles
44
id_from_query_path: response
5+
id_from_query_path_attribute: id
6+
import_no_id: true
57
get_from_all: true
6-
no_data_source: true
7-
put_no_id: true
8-
id_from_query_path_attribute: instanceUuid
98
res_description:
109
'This resource creates a wireless network profile. To associate a wireless network profile with a site, use
1110
the `catalystcenter_associate_site_to_network_profile` resource.'
1211
doc_category: Wireless
1312
attributes:
1413
- model_name: wirelessProfileName
15-
tf_name: name
16-
delete_query_param_name: name
17-
delete_query_param: true
1814
type: String
1915
match_id: true
20-
description: Profile Name
16+
description: Wireless Network Profile Name
2117
example: Wireless_Profile_1
2218
- model_name: ssidDetails
2319
type: List
2420
description: SSID Details
2521
attributes:
2622
- model_name: ssidName
27-
tf_name: name
2823
type: String
2924
id: true
30-
description: Ssid Name
25+
description: SSID Name
3126
example: mySSID1
3227
test_value: catalystcenter_wireless_enterprise_ssid.test.name
3328
- model_name: enableFabric
3429
type: Bool
35-
description: "`true` if ssid is fabric else `false`"
30+
description: "True if fabric is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time"
3631
example: true
3732
- model_name: enableFlexConnect
3833
data_path: flexConnect
3934
type: Bool
40-
description: "`true` if flex connect is enabled else `false`"
35+
description: "True if flex connect is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time"
4136
example: false
4237
- model_name: localToVlan
4338
data_path: flexConnect
@@ -49,19 +44,17 @@ attributes:
4944
type: String
5045
description: Interface Name
5146
exclude_test: true
47+
default_value: management
5248
example: management
5349
- model_name: wlanProfileName
54-
write_only: true
5550
type: String
5651
description: WLAN Profile Name
5752
exclude_test: true
5853
example: mySSID1_profile
59-
- model_name: policyProfileName
60-
write_only: true
54+
- model_name: dot11beProfileId
6155
type: String
62-
description: Policy Profile Name
56+
description: 802.11be Profile Id. Applicable to IOS controllers with version 17.15 and higher. 802.11be Profiles if passed, should be same across all SSIDs in network profile being configured
6357
exclude_test: true
64-
example: mySSID1_profile
6558
test_prerequisites: |
6659
resource "catalystcenter_wireless_enterprise_ssid" "test" {
6760
name = "mySSID1"
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
2+
// All rights reserved.
3+
//
4+
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://mozilla.org/MPL/2.0/
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
// SPDX-License-Identifier: MPL-2.0
17+
18+
package provider
19+
20+
// Section below is generated&owned by "gen/generator.go". //template:begin imports
21+
import (
22+
"context"
23+
"fmt"
24+
25+
"github.com/hashicorp/terraform-plugin-framework/datasource"
26+
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
27+
"github.com/hashicorp/terraform-plugin-log/tflog"
28+
cc "github.com/netascode/go-catalystcenter"
29+
)
30+
31+
// End of section. //template:end imports
32+
33+
// Section below is generated&owned by "gen/generator.go". //template:begin model
34+
35+
// Ensure the implementation satisfies the expected interfaces.
36+
var (
37+
_ datasource.DataSource = &WirelessProfileDataSource{}
38+
_ datasource.DataSourceWithConfigure = &WirelessProfileDataSource{}
39+
)
40+
41+
func NewWirelessProfileDataSource() datasource.DataSource {
42+
return &WirelessProfileDataSource{}
43+
}
44+
45+
type WirelessProfileDataSource struct {
46+
client *cc.Client
47+
}
48+
49+
func (d *WirelessProfileDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
50+
resp.TypeName = req.ProviderTypeName + "_wireless_profile"
51+
}
52+
53+
func (d *WirelessProfileDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
54+
resp.Schema = schema.Schema{
55+
// This description is used by the documentation generator and the language server.
56+
MarkdownDescription: "This data source can read the Wireless Profile.",
57+
58+
Attributes: map[string]schema.Attribute{
59+
"id": schema.StringAttribute{
60+
MarkdownDescription: "The id of the object",
61+
Required: true,
62+
},
63+
"wireless_profile_name": schema.StringAttribute{
64+
MarkdownDescription: "Wireless Network Profile Name",
65+
Computed: true,
66+
},
67+
"ssid_details": schema.ListNestedAttribute{
68+
MarkdownDescription: "SSID Details",
69+
Computed: true,
70+
NestedObject: schema.NestedAttributeObject{
71+
Attributes: map[string]schema.Attribute{
72+
"ssid_name": schema.StringAttribute{
73+
MarkdownDescription: "SSID Name",
74+
Computed: true,
75+
},
76+
"enable_fabric": schema.BoolAttribute{
77+
MarkdownDescription: "True if fabric is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time",
78+
Computed: true,
79+
},
80+
"enable_flex_connect": schema.BoolAttribute{
81+
MarkdownDescription: "True if flex connect is enabled, else False. Flex and fabric cannot be enabled simultaneously and a profile can only contain either flex SSIDs or fabric SSIDs and not both at the same time",
82+
Computed: true,
83+
},
84+
"local_to_vlan": schema.Int64Attribute{
85+
MarkdownDescription: "Local To Vlan Id",
86+
Computed: true,
87+
},
88+
"interface_name": schema.StringAttribute{
89+
MarkdownDescription: "Interface Name",
90+
Computed: true,
91+
},
92+
"wlan_profile_name": schema.StringAttribute{
93+
MarkdownDescription: "WLAN Profile Name",
94+
Computed: true,
95+
},
96+
"dot11be_profile_id": schema.StringAttribute{
97+
MarkdownDescription: "802.11be Profile Id. Applicable to IOS controllers with version 17.15 and higher. 802.11be Profiles if passed, should be same across all SSIDs in network profile being configured",
98+
Computed: true,
99+
},
100+
},
101+
},
102+
},
103+
},
104+
}
105+
}
106+
107+
func (d *WirelessProfileDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) {
108+
if req.ProviderData == nil {
109+
return
110+
}
111+
112+
d.client = req.ProviderData.(*CcProviderData).Client
113+
}
114+
115+
// End of section. //template:end model
116+
117+
// Section below is generated&owned by "gen/generator.go". //template:begin read
118+
func (d *WirelessProfileDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
119+
var config WirelessProfile
120+
121+
// Read config
122+
diags := req.Config.Get(ctx, &config)
123+
resp.Diagnostics.Append(diags...)
124+
if resp.Diagnostics.HasError() {
125+
return
126+
}
127+
128+
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))
129+
130+
params := ""
131+
res, err := d.client.Get(config.getPath() + params)
132+
if err != nil {
133+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
134+
return
135+
}
136+
res = res.Get("response.#(id==\"" + config.Id.ValueString() + "\")")
137+
138+
config.fromBody(ctx, res)
139+
140+
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString()))
141+
142+
diags = resp.State.Set(ctx, &config)
143+
resp.Diagnostics.Append(diags...)
144+
}
145+
146+
// End of section. //template:end read

0 commit comments

Comments
 (0)