Skip to content

Update wireless_profile resource to use new api intent/api/v1/wirelessProfiles #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c95fc8e
added GenerateQueryParamString templating helper function
kuba-mazurkiewicz Jul 19, 2024
b853a94
use create_query_path instead of query_param in Create and Update fun…
kuba-mazurkiewicz Jul 19, 2024
d0e2c6f
add query_param_no_body and data_source_no_id attributes
kuba-mazurkiewicz Jul 20, 2024
c1381fd
add import_no_id attribute, if import does not require and ID
kuba-mazurkiewicz Jul 20, 2024
a98ad26
add anycast_gateway
kuba-mazurkiewicz Jul 20, 2024
5545db0
update changelog
kuba-mazurkiewicz Jul 20, 2024
9c69bd5
add transitPeerNetworkId as id to transit_peer_network resource
kuba-mazurkiewicz Jul 20, 2024
c70bd2a
updated changelog
kuba-mazurkiewicz Jul 20, 2024
38d93bf
add fabric_l3_handoff_ip_transit resource and data source
kuba-mazurkiewicz Jul 21, 2024
59173f3
add fabric_device resource and data source
kuba-mazurkiewicz Jul 21, 2024
522d49c
pnp bulk import
kuba-mazurkiewicz Jul 22, 2024
30854ad
update changelog
kuba-mazurkiewicz Jul 22, 2024
9a6533c
rename pnp_device_import to pnp_import_devices
kuba-mazurkiewicz Jul 24, 2024
35565f0
add tag and assign_templates_to_tag
kuba-mazurkiewicz Jul 26, 2024
241fe0a
changed template_ids from List to Set
kuba-mazurkiewicz Jul 26, 2024
2db5bce
update changelog
kuba-mazurkiewicz Jul 26, 2024
b10aeaa
add fabric_provision_device resource and data source
kuba-mazurkiewicz Jul 30, 2024
f478bfb
modified max_async_wait_time in fabric_device resource
kuba-mazurkiewicz Jul 31, 2024
25435ac
modified max_async_wait_time in fabric_provision_device resource
kuba-mazurkiewicz Jul 31, 2024
01fefd8
add wireless_device_provision, add additional params in enterprise_ss…
kuba-mazurkiewicz Aug 1, 2024
4906ccb
update changelog
kuba-mazurkiewicz Aug 1, 2024
9f31f09
Merge branch 'main' into tags_to_template
kuba-mazurkiewicz Aug 5, 2024
df90953
update changelog
kuba-mazurkiewicz Aug 5, 2024
c8291fd
modified res_description
kuba-mazurkiewicz Aug 5, 2024
7252a29
Merge branch 'tags_to_template' into provision_sda
kuba-mazurkiewicz Aug 5, 2024
efa562b
Merge branch 'provision_sda' into fix_provision_borders
kuba-mazurkiewicz Aug 5, 2024
9a02a97
fix data source test for resources with data_source_no_id: true
kuba-mazurkiewicz Aug 5, 2024
7b1404d
fix confilcts
kuba-mazurkiewicz Aug 5, 2024
efb6157
update changelog
kuba-mazurkiewicz Aug 5, 2024
a7d936f
fix typo in virtualNetworkName description in fabric_l3_handoff_ip_tr…
kuba-mazurkiewicz Aug 5, 2024
d3c42c2
modified wireless_profile to use new endpoint /intent/api/v1/wireless…
kuba-mazurkiewicz Aug 6, 2024
ce879d8
add test tag CC2376 to wireles_profile resource
kuba-mazurkiewicz Aug 6, 2024
f74ce30
update changelog
kuba-mazurkiewicz Aug 6, 2024
7d3ba2f
removed test tag from wireless_profile
kuba-mazurkiewicz Aug 7, 2024
4496a67
removed ghz24_policy from test prerequisites
kuba-mazurkiewicz Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.1.10 (unreleased)

- 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+
- Add `wireless_device_provision` resource
- Add `fabric_provision_device` resource and data source
- Add `assign_templates_to_tag` resource and data source
Expand Down
44 changes: 44 additions & 0 deletions docs/data-sources/wireless_profile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_wireless_profile Data Source - terraform-provider-catalystcenter"
subcategory: "Wireless"
description: |-
This data source can read the Wireless Profile.
---

# catalystcenter_wireless_profile (Data Source)

This data source can read the Wireless Profile.

## Example Usage

```terraform
data "catalystcenter_wireless_profile" "example" {
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The id of the object

### Read-Only

- `ssid_details` (Attributes List) SSID Details (see [below for nested schema](#nestedatt--ssid_details))
- `wireless_profile_name` (String) Wireless Network Profile Name

<a id="nestedatt--ssid_details"></a>
### Nested Schema for `ssid_details`

Read-Only:

- `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
- `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
- `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
- `interface_name` (String) Interface Name
- `local_to_vlan` (Number) Local To Vlan Id
- `ssid_name` (String) SSID Name
- `wlan_profile_name` (String) WLAN Profile Name
1 change: 1 addition & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description: |-

## 0.1.10 (unreleased)

- 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+
- Add `wireless_device_provision` resource
- Add `fabric_provision_device` resource and data source
- Add `assign_templates_to_tag` resource and data source
Expand Down
17 changes: 9 additions & 8 deletions docs/resources/wireless_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ This resource creates a wireless network profile. To associate a wireless networ

```terraform
resource "catalystcenter_wireless_profile" "example" {
name = "Wireless_Profile_1"
wireless_profile_name = "Wireless_Profile_1"
ssid_details = [
{
name = "mySSID1"
ssid_name = "mySSID1"
enable_fabric = true
enable_flex_connect = false
}
Expand All @@ -30,7 +30,7 @@ resource "catalystcenter_wireless_profile" "example" {

### Required

- `name` (String) Profile Name
- `wireless_profile_name` (String) Wireless Network Profile Name

### Optional

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

Required:

- `name` (String) Ssid Name
- `ssid_name` (String) SSID Name

Optional:

- `enable_fabric` (Boolean) `true` if ssid is fabric else `false`
- `enable_flex_connect` (Boolean) `true` if flex connect is enabled else `false`
- `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
- `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
- `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
- `interface_name` (String) Interface Name
- Default value: `management`
- `local_to_vlan` (Number) Local To Vlan Id
- `policy_profile_name` (String) Policy Profile Name
- `wlan_profile_name` (String) WLAN Profile Name

## Import

Import is supported using the following syntax:

```shell
terraform import catalystcenter_wireless_profile.example "<id>"
terraform import catalystcenter_wireless_profile.example "4b0b7a80-44c0-4bf2-bab5-fc24b4e0a17e"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "catalystcenter_wireless_profile" "example" {
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
terraform import catalystcenter_wireless_profile.example "<id>"
terraform import catalystcenter_wireless_profile.example "4b0b7a80-44c0-4bf2-bab5-fc24b4e0a17e"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "catalystcenter_wireless_profile" "example" {
name = "Wireless_Profile_1"
wireless_profile_name = "Wireless_Profile_1"
ssid_details = [
{
name = "mySSID1"
ssid_name = "mySSID1"
enable_fabric = true
enable_flex_connect = false
}
Expand Down
27 changes: 10 additions & 17 deletions gen/definitions/wireless_profile.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
---
name: Wireless Profile
rest_endpoint: /dna/intent/api/v2/wireless/profile
rest_endpoint: /intent/api/v1/wirelessProfiles
id_from_query_path: response
id_from_query_path_attribute: id
import_no_id: true
get_from_all: true
no_data_source: true
put_no_id: true
id_from_query_path_attribute: instanceUuid
res_description:
'This resource creates a wireless network profile. To associate a wireless network profile with a site, use
the `catalystcenter_associate_site_to_network_profile` resource.'
doc_category: Wireless
attributes:
- model_name: wirelessProfileName
tf_name: name
delete_query_param_name: name
delete_query_param: true
type: String
match_id: true
description: Profile Name
description: Wireless Network Profile Name
example: Wireless_Profile_1
- model_name: ssidDetails
type: List
description: SSID Details
attributes:
- model_name: ssidName
tf_name: name
type: String
id: true
description: Ssid Name
description: SSID Name
example: mySSID1
test_value: catalystcenter_wireless_enterprise_ssid.test.name
- model_name: enableFabric
type: Bool
description: "`true` if ssid is fabric else `false`"
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"
example: true
- model_name: enableFlexConnect
data_path: flexConnect
type: Bool
description: "`true` if flex connect is enabled else `false`"
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"
example: false
- model_name: localToVlan
data_path: flexConnect
Expand All @@ -49,19 +44,17 @@ attributes:
type: String
description: Interface Name
exclude_test: true
default_value: management
example: management
- model_name: wlanProfileName
write_only: true
type: String
description: WLAN Profile Name
exclude_test: true
example: mySSID1_profile
- model_name: policyProfileName
write_only: true
- model_name: dot11beProfileId
type: String
description: Policy Profile Name
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
exclude_test: true
example: mySSID1_profile
test_prerequisites: |
resource "catalystcenter_wireless_enterprise_ssid" "test" {
name = "mySSID1"
Expand Down
146 changes: 146 additions & 0 deletions internal/provider/data_source_catalystcenter_wireless_profile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
cc "github.com/netascode/go-catalystcenter"
)

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin model

// Ensure the implementation satisfies the expected interfaces.
var (
_ datasource.DataSource = &WirelessProfileDataSource{}
_ datasource.DataSourceWithConfigure = &WirelessProfileDataSource{}
)

func NewWirelessProfileDataSource() datasource.DataSource {
return &WirelessProfileDataSource{}
}

type WirelessProfileDataSource struct {
client *cc.Client
}

func (d *WirelessProfileDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_wireless_profile"
}

func (d *WirelessProfileDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
// This description is used by the documentation generator and the language server.
MarkdownDescription: "This data source can read the Wireless Profile.",

Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
MarkdownDescription: "The id of the object",
Required: true,
},
"wireless_profile_name": schema.StringAttribute{
MarkdownDescription: "Wireless Network Profile Name",
Computed: true,
},
"ssid_details": schema.ListNestedAttribute{
MarkdownDescription: "SSID Details",
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"ssid_name": schema.StringAttribute{
MarkdownDescription: "SSID Name",
Computed: true,
},
"enable_fabric": schema.BoolAttribute{
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",
Computed: true,
},
"enable_flex_connect": schema.BoolAttribute{
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",
Computed: true,
},
"local_to_vlan": schema.Int64Attribute{
MarkdownDescription: "Local To Vlan Id",
Computed: true,
},
"interface_name": schema.StringAttribute{
MarkdownDescription: "Interface Name",
Computed: true,
},
"wlan_profile_name": schema.StringAttribute{
MarkdownDescription: "WLAN Profile Name",
Computed: true,
},
"dot11be_profile_id": schema.StringAttribute{
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",
Computed: true,
},
},
},
},
},
}
}

func (d *WirelessProfileDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) {
if req.ProviderData == nil {
return
}

d.client = req.ProviderData.(*CcProviderData).Client
}

// End of section. //template:end model

// Section below is generated&owned by "gen/generator.go". //template:begin read
func (d *WirelessProfileDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config WirelessProfile

// Read config
diags := req.Config.Get(ctx, &config)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}

tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))

params := ""
res, err := d.client.Get(config.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
return
}
res = res.Get("response.#(id==\"" + config.Id.ValueString() + "\")")

config.fromBody(ctx, res)

tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString()))

diags = resp.State.Set(ctx, &config)
resp.Diagnostics.Append(diags...)
}

// End of section. //template:end read
Loading