Skip to content

Commit 180b15b

Browse files
authored
Update minimum FMC version for file_type and file_category data sources (#174)
1 parent 3c63371 commit 180b15b

File tree

112 files changed

+437
-499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+437
-499
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 2.0.0-beta2 (Unreleased)
22

3+
- (Fix) Update minimum FMC version for `file_type` and `file_category` data sources
34
- (Fix) Align fields in ipv4/ipv6/vrf_ipv4/vrf_ipv6 static_route resources
45
- (Enhancement) Add `type` field to multiple resources
56

docs/data-sources/file_categories.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ page_title: "fmc_file_categories Data Source - terraform-provider-fmc"
44
subcategory: "Objects"
55
description: |-
66
This data source reads the File Categories.
7+
The following restrictions apply:
8+
Minimum FMC version: 7.4
79
---
810

911
# fmc_file_categories (Data Source)
1012

1113
This data source reads the File Categories.
1214

15+
The following restrictions apply:
16+
- Minimum FMC version: `7.4`
17+
1318
## Example Usage
1419

1520
```terraform

docs/data-sources/file_category.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ page_title: "fmc_file_category Data Source - terraform-provider-fmc"
44
subcategory: "Objects"
55
description: |-
66
This data source reads the File Category.
7+
The following restrictions apply:
8+
Minimum FMC version: 7.4
79
---
810

911
# fmc_file_category (Data Source)
1012

1113
This data source reads the File Category.
1214

15+
The following restrictions apply:
16+
- Minimum FMC version: `7.4`
17+
1318
## Example Usage
1419

1520
```terraform

docs/data-sources/file_type.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ page_title: "fmc_file_type Data Source - terraform-provider-fmc"
44
subcategory: "Objects"
55
description: |-
66
This data source reads the File Type.
7+
The following restrictions apply:
8+
Minimum FMC version: 7.4
79
---
810

911
# fmc_file_type (Data Source)
1012

1113
This data source reads the File Type.
1214

15+
The following restrictions apply:
16+
- Minimum FMC version: `7.4`
17+
1318
## Example Usage
1419

1520
```terraform

docs/data-sources/file_types.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ page_title: "fmc_file_types Data Source - terraform-provider-fmc"
44
subcategory: "Objects"
55
description: |-
66
This data source reads the File Types.
7+
The following restrictions apply:
8+
Minimum FMC version: 7.4
79
---
810

911
# fmc_file_types (Data Source)
1012

1113
This data source reads the File Types.
1214

15+
The following restrictions apply:
16+
- Minimum FMC version: `7.4`
17+
1318
## Example Usage
1419

1520
```terraform

docs/guides/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: |-
99

1010
## 2.0.0-beta2 (Unreleased)
1111

12+
- (Fix) Update minimum FMC version for `file_type` and `file_category` data sources
1213
- (Fix) Align fields in ipv4/ipv6/vrf_ipv4/vrf_ipv6 static_route resources
1314
- (Enhancement) Add `type` field to multiple resources
1415

gen/definitions/file_categories.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rest_endpoint: /api/fmc_config/v1/domain/{DOMAIN_UUID}/object/filecategories
44
no_resource: true
55
no_import: true
66
is_bulk: true
7+
minimum_version: "7.4"
78
doc_category: Objects
89
attributes:
910
- model_name: items

gen/definitions/file_category.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rest_endpoint: /api/fmc_config/v1/domain/{DOMAIN_UUID}/object/filecategories
44
no_resource: true
55
no_import: true
66
doc_category: Objects
7+
minimum_version: "7.4"
78
attributes:
89
- model_name: name
910
type: String

gen/definitions/file_type.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rest_endpoint: /api/fmc_config/v1/domain/{DOMAIN_UUID}/object/filetypes
44
no_resource: true
55
no_import: true
66
doc_category: Objects
7+
minimum_version: "7.4"
78
attributes:
89
- model_name: name
910
type: String

gen/definitions/file_types.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ no_resource: true
55
no_import: true
66
is_bulk: true
77
doc_category: Objects
8+
minimum_version: "7.4"
89
attributes:
910
- model_name: items
1011
type: Map

gen/templates/model.go

+20
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ type {{.GoTypeName}} struct {
128128

129129
// End of section. //template:end types
130130

131+
// Section below is generated&owned by "gen/generator.go". //template:begin minimumVersions
132+
133+
{{- if .MinimumVersion}}
134+
var minFMCVersion{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersion}}"))
135+
{{- end}}
136+
{{- if .MinimumVersionCreate}}
137+
var minFMCVersionCreate{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersionCreate}}"))
138+
{{- end}}
139+
{{- if .MinimumVersionBulkCreate}}
140+
var minFMCVersionBulkCreate{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersionBulkCreate}}"))
141+
{{- end}}
142+
{{- if .MinimumVersionBulkDelete}}
143+
var minFMCVersionBulkDelete{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersionBulkDelete}}"))
144+
{{- end}}
145+
{{- if .BulkSizeCreate}}
146+
const bulkSizeCreate{{camelCase .Name}} int = {{.BulkSizeCreate}}
147+
{{- end}}
148+
149+
// End of section. //template:end minimumVersions
150+
131151
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
132152

133153
func (data {{camelCase .Name}}) getPath() string {

gen/templates/resource.go

-16
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,6 @@ var (
5656
{{- end}}
5757
)
5858

59-
{{- if .MinimumVersion}}
60-
var minFMCVersion{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersion}}"))
61-
{{- end}}
62-
{{- if .MinimumVersionCreate}}
63-
var minFMCVersionCreate{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersionCreate}}"))
64-
{{- end}}
65-
{{- if .MinimumVersionBulkCreate}}
66-
var minFMCVersionBulkCreate{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersionBulkCreate}}"))
67-
{{- end}}
68-
{{- if .MinimumVersionBulkDelete}}
69-
var minFMCVersionBulkDelete{{camelCase .Name}} = version.Must(version.NewVersion("{{.MinimumVersionBulkDelete}}"))
70-
{{- end}}
71-
{{- if .BulkSizeCreate}}
72-
const bulkSizeCreate{{camelCase .Name}} int = {{.BulkSizeCreate}}
73-
{{- end}}
74-
7559
func New{{camelCase .Name}}Resource() resource.Resource {
7660
return &{{camelCase .Name}}Resource{}
7761
}

internal/provider/data_source_fmc_file_categories.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ package provider
2121
import (
2222
"context"
2323
"fmt"
24+
"strings"
2425

2526
"github.com/CiscoDevNet/terraform-provider-fmc/internal/provider/helpers"
27+
"github.com/hashicorp/go-version"
2628
"github.com/hashicorp/terraform-plugin-framework/datasource"
2729
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
2830
"github.com/hashicorp/terraform-plugin-log/tflog"
@@ -54,7 +56,7 @@ func (d *FileCategoriesDataSource) Metadata(_ context.Context, req datasource.Me
5456
func (d *FileCategoriesDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
5557
resp.Schema = schema.Schema{
5658
// This description is used by the documentation generator and the language server.
57-
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Categories.").String,
59+
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Categories.").AddMinimumVersionHeaderDescription().AddMinimumVersionDescription("7.4").String,
5860

5961
Attributes: map[string]schema.Attribute{
6062
"id": schema.StringAttribute{
@@ -99,6 +101,14 @@ func (d *FileCategoriesDataSource) Configure(_ context.Context, req datasource.C
99101
// Section below is generated&owned by "gen/generator.go". //template:begin read
100102

101103
func (d *FileCategoriesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
104+
// Get FMC version
105+
fmcVersion, _ := version.NewVersion(strings.Split(d.client.FMCVersion, " ")[0])
106+
107+
// Check if FMC client is connected to supports this object
108+
if fmcVersion.LessThan(minFMCVersionFileCategories) {
109+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("UnsupportedVersion: FMC version %s does not support File Categories, minimum required version is 7.4", d.client.FMCVersion))
110+
return
111+
}
102112
var config FileCategories
103113

104114
// Read config

internal/provider/data_source_fmc_file_category.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ import (
2222
"context"
2323
"fmt"
2424
"net/url"
25+
"strings"
2526

2627
"github.com/CiscoDevNet/terraform-provider-fmc/internal/provider/helpers"
28+
"github.com/hashicorp/go-version"
2729
"github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
2830
"github.com/hashicorp/terraform-plugin-framework/datasource"
2931
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@@ -59,7 +61,7 @@ func (d *FileCategoryDataSource) Metadata(_ context.Context, req datasource.Meta
5961
func (d *FileCategoryDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
6062
resp.Schema = schema.Schema{
6163
// This description is used by the documentation generator and the language server.
62-
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Category.").String,
64+
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Category.").AddMinimumVersionHeaderDescription().AddMinimumVersionDescription("7.4").String,
6365

6466
Attributes: map[string]schema.Attribute{
6567
"id": schema.StringAttribute{
@@ -105,6 +107,14 @@ func (d *FileCategoryDataSource) Configure(_ context.Context, req datasource.Con
105107
// Section below is generated&owned by "gen/generator.go". //template:begin read
106108

107109
func (d *FileCategoryDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
110+
// Get FMC version
111+
fmcVersion, _ := version.NewVersion(strings.Split(d.client.FMCVersion, " ")[0])
112+
113+
// Check if FMC client is connected to supports this object
114+
if fmcVersion.LessThan(minFMCVersionFileCategory) {
115+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("UnsupportedVersion: FMC version %s does not support File Category, minimum required version is 7.4", d.client.FMCVersion))
116+
return
117+
}
108118
var config FileCategory
109119

110120
// Read config

internal/provider/data_source_fmc_file_type.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ import (
2222
"context"
2323
"fmt"
2424
"net/url"
25+
"strings"
2526

2627
"github.com/CiscoDevNet/terraform-provider-fmc/internal/provider/helpers"
28+
"github.com/hashicorp/go-version"
2729
"github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
2830
"github.com/hashicorp/terraform-plugin-framework/datasource"
2931
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@@ -59,7 +61,7 @@ func (d *FileTypeDataSource) Metadata(_ context.Context, req datasource.Metadata
5961
func (d *FileTypeDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
6062
resp.Schema = schema.Schema{
6163
// This description is used by the documentation generator and the language server.
62-
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Type.").String,
64+
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Type.").AddMinimumVersionHeaderDescription().AddMinimumVersionDescription("7.4").String,
6365

6466
Attributes: map[string]schema.Attribute{
6567
"id": schema.StringAttribute{
@@ -105,6 +107,14 @@ func (d *FileTypeDataSource) Configure(_ context.Context, req datasource.Configu
105107
// Section below is generated&owned by "gen/generator.go". //template:begin read
106108

107109
func (d *FileTypeDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
110+
// Get FMC version
111+
fmcVersion, _ := version.NewVersion(strings.Split(d.client.FMCVersion, " ")[0])
112+
113+
// Check if FMC client is connected to supports this object
114+
if fmcVersion.LessThan(minFMCVersionFileType) {
115+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("UnsupportedVersion: FMC version %s does not support File Type, minimum required version is 7.4", d.client.FMCVersion))
116+
return
117+
}
108118
var config FileType
109119

110120
// Read config

internal/provider/data_source_fmc_file_types.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ package provider
2121
import (
2222
"context"
2323
"fmt"
24+
"strings"
2425

2526
"github.com/CiscoDevNet/terraform-provider-fmc/internal/provider/helpers"
27+
"github.com/hashicorp/go-version"
2628
"github.com/hashicorp/terraform-plugin-framework/datasource"
2729
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
2830
"github.com/hashicorp/terraform-plugin-log/tflog"
@@ -54,7 +56,7 @@ func (d *FileTypesDataSource) Metadata(_ context.Context, req datasource.Metadat
5456
func (d *FileTypesDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
5557
resp.Schema = schema.Schema{
5658
// This description is used by the documentation generator and the language server.
57-
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Types.").String,
59+
MarkdownDescription: helpers.NewAttributeDescription("This data source reads the File Types.").AddMinimumVersionHeaderDescription().AddMinimumVersionDescription("7.4").String,
5860

5961
Attributes: map[string]schema.Attribute{
6062
"id": schema.StringAttribute{
@@ -99,6 +101,14 @@ func (d *FileTypesDataSource) Configure(_ context.Context, req datasource.Config
99101
// Section below is generated&owned by "gen/generator.go". //template:begin read
100102

101103
func (d *FileTypesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
104+
// Get FMC version
105+
fmcVersion, _ := version.NewVersion(strings.Split(d.client.FMCVersion, " ")[0])
106+
107+
// Check if FMC client is connected to supports this object
108+
if fmcVersion.LessThan(minFMCVersionFileTypes) {
109+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("UnsupportedVersion: FMC version %s does not support File Types, minimum required version is 7.4", d.client.FMCVersion))
110+
return
111+
}
102112
var config FileTypes
103113

104114
// Read config

internal/provider/model_fmc_access_control_policy.go

+4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ func (r AccessControlPolicyRules) GetSection() string {
203203
return "default"
204204
}
205205

206+
// Section below is generated&owned by "gen/generator.go". //template:begin minimumVersions
207+
208+
// End of section. //template:end minimumVersions
209+
206210
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
207211

208212
func (data AccessControlPolicy) getPath() string {

internal/provider/model_fmc_bfd_template.go

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package provider
2121
import (
2222
"context"
2323

24+
"github.com/hashicorp/go-version"
2425
"github.com/hashicorp/terraform-plugin-framework/types"
2526
"github.com/tidwall/gjson"
2627
"github.com/tidwall/sjson"
@@ -49,6 +50,11 @@ type BFDTemplate struct {
4950

5051
// End of section. //template:end types
5152

53+
// Section below is generated&owned by "gen/generator.go". //template:begin minimumVersions
54+
var minFMCVersionBFDTemplate = version.Must(version.NewVersion("7.4"))
55+
56+
// End of section. //template:end minimumVersions
57+
5258
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
5359

5460
func (data BFDTemplate) getPath() string {

internal/provider/model_fmc_device.go

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ type Device struct {
5454

5555
// End of section. //template:end types
5656

57+
// Section below is generated&owned by "gen/generator.go". //template:begin minimumVersions
58+
59+
// End of section. //template:end minimumVersions
60+
5761
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
5862

5963
func (data Device) getPath() string {

internal/provider/model_fmc_device_bfd.go

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"fmt"
2424
"net/url"
2525

26+
"github.com/hashicorp/go-version"
2627
"github.com/hashicorp/terraform-plugin-framework/types"
2728
"github.com/tidwall/gjson"
2829
"github.com/tidwall/sjson"
@@ -48,6 +49,11 @@ type DeviceBFD struct {
4849

4950
// End of section. //template:end types
5051

52+
// Section below is generated&owned by "gen/generator.go". //template:begin minimumVersions
53+
var minFMCVersionDeviceBFD = version.Must(version.NewVersion("7.4"))
54+
55+
// End of section. //template:end minimumVersions
56+
5157
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
5258

5359
func (data DeviceBFD) getPath() string {

internal/provider/model_fmc_device_bgp.go

+4
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ type DeviceBGPIpv4NeighborsNeighborFilterAsPathLists struct {
158158

159159
// End of section. //template:end types
160160

161+
// Section below is generated&owned by "gen/generator.go". //template:begin minimumVersions
162+
163+
// End of section. //template:end minimumVersions
164+
161165
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
162166

163167
func (data DeviceBGP) getPath() string {

internal/provider/model_fmc_device_bgp_general_settings.go

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ type DeviceBGPGeneralSettings struct {
6464

6565
// End of section. //template:end types
6666

67+
// Section below is generated&owned by "gen/generator.go". //template:begin minimumVersions
68+
69+
// End of section. //template:end minimumVersions
70+
6771
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
6872

6973
func (data DeviceBGPGeneralSettings) getPath() string {

0 commit comments

Comments
 (0)