diff --git a/pkg/config-api-provider/examples/full-demo/main.tf b/pkg/config-api-provider/examples/full-demo/main.tf index 3a74a0e2..565da15c 100644 --- a/pkg/config-api-provider/examples/full-demo/main.tf +++ b/pkg/config-api-provider/examples/full-demo/main.tf @@ -82,7 +82,7 @@ removed { } */ resource "uxi_wireless_network" "my_wireless_network" { - alias = "alias" + name = "name" } import { @@ -102,7 +102,7 @@ removed { } */ resource "uxi_wired_network" "my_wired_network" { - alias = "alias" + name = "name" } import { @@ -121,7 +121,7 @@ removed { } */ resource "uxi_service_test" "my_service_test" { - title = "title" + name = "name" } import { diff --git a/pkg/config-api-provider/provider/data-sources/wired_network.go b/pkg/config-api-provider/provider/data-sources/wired_network.go index dbd13d18..f283cd27 100644 --- a/pkg/config-api-provider/provider/data-sources/wired_network.go +++ b/pkg/config-api-provider/provider/data-sources/wired_network.go @@ -26,7 +26,7 @@ type wiredNetworkDataSource struct { type wiredNetworkDataSourceModel struct { ID types.String `tfsdk:"id"` - Alias types.String `tfsdk:"alias"` + Name types.String `tfsdk:"name"` IpVersion types.String `tfsdk:"ip_version"` Security types.String `tfsdk:"security"` DnsLookupDomain types.String `tfsdk:"dns_lookup_domain"` @@ -50,7 +50,7 @@ func (d *wiredNetworkDataSource) Schema(_ context.Context, _ datasource.SchemaRe "id": schema.StringAttribute{ Computed: true, }, - "alias": schema.StringAttribute{ + "name": schema.StringAttribute{ Computed: true, }, "ip_version": schema.StringAttribute{ @@ -116,7 +116,7 @@ func (d *wiredNetworkDataSource) Read(ctx context.Context, req datasource.ReadRe network := networkResponse.Items[0] state.ID = types.StringValue(network.Id) - state.Alias = types.StringValue(network.Name) + state.Name = types.StringValue(network.Name) state.IpVersion = types.StringValue(network.IpVersion) state.Security = types.StringValue(*network.Security.Get()) state.DnsLookupDomain = types.StringValue(*network.DnsLookupDomain.Get()) diff --git a/pkg/config-api-provider/provider/data-sources/wireless_network.go b/pkg/config-api-provider/provider/data-sources/wireless_network.go index 60cb6a01..61972da1 100644 --- a/pkg/config-api-provider/provider/data-sources/wireless_network.go +++ b/pkg/config-api-provider/provider/data-sources/wireless_network.go @@ -27,7 +27,7 @@ type wirelessNetworkDataSource struct { type wirelessNetworkDataSourceModel struct { ID types.String `tfsdk:"id"` Ssid types.String `tfsdk:"ssid"` - Alias types.String `tfsdk:"alias"` + Name types.String `tfsdk:"name"` IpVersion types.String `tfsdk:"ip_version"` Security types.String `tfsdk:"security"` Hidden types.Bool `tfsdk:"hidden"` @@ -55,7 +55,7 @@ func (d *wirelessNetworkDataSource) Schema(_ context.Context, _ datasource.Schem "ssid": schema.StringAttribute{ Computed: true, }, - "alias": schema.StringAttribute{ + "name": schema.StringAttribute{ Computed: true, }, "ip_version": schema.StringAttribute{ @@ -125,7 +125,7 @@ func (d *wirelessNetworkDataSource) Read(ctx context.Context, req datasource.Rea network := networkResponse.Items[0] state.ID = types.StringValue(network.Id) state.Ssid = types.StringValue(network.Ssid) - state.Alias = types.StringValue(network.Name) + state.Name = types.StringValue(network.Name) state.IpVersion = types.StringValue(network.IpVersion) state.Security = types.StringValue(*network.Security.Get()) state.Hidden = types.BoolValue(network.Hidden) diff --git a/pkg/config-api-provider/provider/resources/service.go b/pkg/config-api-provider/provider/resources/service.go index 288e634c..e3990cdf 100644 --- a/pkg/config-api-provider/provider/resources/service.go +++ b/pkg/config-api-provider/provider/resources/service.go @@ -19,15 +19,15 @@ var ( ) type serviceTestResourceModel struct { - ID types.String `tfsdk:"id"` - Title types.String `tfsdk:"title"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` } // TODO: Switch this to use the Client Model when that becomes available type ServiceTestResponseModel struct { Uid string // , Category string // , - Title string // , + Name string // , Target string // Nullable<>, Template string // , IsEnabled bool // @@ -52,7 +52,7 @@ func (r *serviceTestResource) Schema(_ context.Context, _ resource.SchemaRequest stringplanmodifier.UseStateForUnknown(), }, }, - "title": schema.StringAttribute{ + "name": schema.StringAttribute{ Required: true, }, }, @@ -82,7 +82,7 @@ func (r *serviceTestResource) Read(ctx context.Context, req resource.ReadRequest response := GetServiceTest(state.ID.ValueString()) // Update state from client response - state.Title = types.StringValue(response.Title) + state.Name = types.StringValue(response.Name) // Set refreshed state diags = resp.State.Set(ctx, &state) @@ -119,7 +119,7 @@ var GetServiceTest = func(uid string) ServiceTestResponseModel { return ServiceTestResponseModel{ Uid: uid, Category: "category", - Title: "title", + Name: "name", Target: "target", Template: "template", IsEnabled: true, diff --git a/pkg/config-api-provider/provider/resources/wired_network.go b/pkg/config-api-provider/provider/resources/wired_network.go index e902a93c..b9eee1ec 100644 --- a/pkg/config-api-provider/provider/resources/wired_network.go +++ b/pkg/config-api-provider/provider/resources/wired_network.go @@ -20,8 +20,8 @@ var ( ) type wiredNetworkResourceModel struct { - ID types.String `tfsdk:"id"` - Alias types.String `tfsdk:"alias"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` } func NewWiredNetworkResource() resource.Resource { @@ -45,7 +45,7 @@ func (r *wiredNetworkResource) Schema(_ context.Context, _ resource.SchemaReques stringplanmodifier.UseStateForUnknown(), }, }, - "alias": schema.StringAttribute{ + "name": schema.StringAttribute{ Required: true, }, }, @@ -110,7 +110,7 @@ func (r *wiredNetworkResource) Read(ctx context.Context, req resource.ReadReques network := networkResponse.Items[0] // Update state from client response - state.Alias = types.StringValue(network.Name) + state.Name = types.StringValue(network.Name) // Set refreshed state diags = resp.State.Set(ctx, &state) diff --git a/pkg/config-api-provider/provider/resources/wireless_network.go b/pkg/config-api-provider/provider/resources/wireless_network.go index 1f0c7c29..ad029364 100644 --- a/pkg/config-api-provider/provider/resources/wireless_network.go +++ b/pkg/config-api-provider/provider/resources/wireless_network.go @@ -20,8 +20,8 @@ var ( ) type wirelessNetworkResourceModel struct { - ID types.String `tfsdk:"id"` - Alias types.String `tfsdk:"alias"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` } func NewWirelessNetworkResource() resource.Resource { @@ -45,7 +45,7 @@ func (r *wirelessNetworkResource) Schema(_ context.Context, _ resource.SchemaReq stringplanmodifier.UseStateForUnknown(), }, }, - "alias": schema.StringAttribute{ + "name": schema.StringAttribute{ Required: true, }, }, @@ -110,7 +110,7 @@ func (r *wirelessNetworkResource) Read(ctx context.Context, req resource.ReadReq network := networkResponse.Items[0] // Update state from client response - state.Alias = types.StringValue(network.Name) + state.Name = types.StringValue(network.Name) // Set refreshed state diags = resp.State.Set(ctx, &state) diff --git a/pkg/config-api-provider/test/data-sources/wired_network_test.go b/pkg/config-api-provider/test/data-sources/wired_network_test.go index ea80fb65..aec5d96c 100644 --- a/pkg/config-api-provider/test/data-sources/wired_network_test.go +++ b/pkg/config-api-provider/test/data-sources/wired_network_test.go @@ -38,7 +38,7 @@ func TestWiredNetworkDataSource(t *testing.T) { `, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "id", "uid"), - resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "alias", "alias"), + resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "name", "name"), resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "ip_version", "ip_version"), resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "security", "security"), resource.TestCheckResourceAttr("data.uxi_wired_network.my_wired_network", "dns_lookup_domain", "dns_lookup_domain"), diff --git a/pkg/config-api-provider/test/data-sources/wireless_network_test.go b/pkg/config-api-provider/test/data-sources/wireless_network_test.go index b1e98de2..b0f3a651 100644 --- a/pkg/config-api-provider/test/data-sources/wireless_network_test.go +++ b/pkg/config-api-provider/test/data-sources/wireless_network_test.go @@ -39,7 +39,7 @@ func TestWirelessNetworkDataSource(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "id", "uid"), resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "ssid", "ssid"), - resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "alias", "alias"), + resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "name", "name"), resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "ip_version", "ip_version"), resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "security", "security"), resource.TestCheckResourceAttr("data.uxi_wireless_network.my_wireless_network", "hidden", "false"), diff --git a/pkg/config-api-provider/test/resources/network_group_assignment_test.go b/pkg/config-api-provider/test/resources/network_group_assignment_test.go index dca10e55..adecd50f 100644 --- a/pkg/config-api-provider/test/resources/network_group_assignment_test.go +++ b/pkg/config-api-provider/test/resources/network_group_assignment_test.go @@ -56,7 +56,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { } resource "uxi_wired_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -140,7 +140,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { } resource "uxi_wired_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -155,7 +155,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { } resource "uxi_wired_network" "my_network_2" { - alias = "alias_2" + name = "name_2" } import { @@ -277,7 +277,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { } resource "uxi_wireless_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -362,7 +362,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { } resource "uxi_wireless_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -377,7 +377,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { } resource "uxi_wireless_network" "my_network_2" { - alias = "alias_2" + name = "name_2" } import { @@ -504,7 +504,7 @@ func TestNetworkGroupAssignmentResource429Handling(t *testing.T) { } resource "uxi_wired_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -611,7 +611,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) { } resource "uxi_wired_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -655,7 +655,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) { } resource "uxi_wired_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -709,7 +709,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) { } resource "uxi_wired_network" "my_network" { - alias = "alias" + name = "name" } import { @@ -766,7 +766,7 @@ func TestNetworkGroupAssignmentResourceHttpErrorHandling(t *testing.T) { } resource "uxi_wired_network" "my_network" { - alias = "alias" + name = "name" } import { diff --git a/pkg/config-api-provider/test/resources/service_test.go b/pkg/config-api-provider/test/resources/service_test.go index 4e08c199..28f286cd 100644 --- a/pkg/config-api-provider/test/resources/service_test.go +++ b/pkg/config-api-provider/test/resources/service_test.go @@ -27,7 +27,7 @@ func TestServiceTestResource(t *testing.T) { { Config: provider.ProviderConfig + ` resource "uxi_service_test" "my_service_test" { - title = "title" + name = "name" }`, ExpectError: regexp.MustCompile(`(?s)creating a service_test is not supported; service_tests can only be\s*imported`), @@ -41,7 +41,7 @@ func TestServiceTestResource(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_service_test" "my_service_test" { - title = "title" + name = "name" } import { @@ -50,7 +50,7 @@ func TestServiceTestResource(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("uxi_service_test.my_service_test", "title", "title"), + resource.TestCheckResourceAttr("uxi_service_test.my_service_test", "name", "name"), resource.TestCheckResourceAttr("uxi_service_test.my_service_test", "id", "uid"), ), }, @@ -64,7 +64,7 @@ func TestServiceTestResource(t *testing.T) { { Config: provider.ProviderConfig + ` resource "uxi_service_test" "my_service_test" { - title = "updated_title" + name = "updated_name" }`, ExpectError: regexp.MustCompile(`(?s)updating a service_test is not supported; service_tests can only be updated\s*through the dashboard`), }, diff --git a/pkg/config-api-provider/test/resources/service_test_group_assignment_test.go b/pkg/config-api-provider/test/resources/service_test_group_assignment_test.go index f1ac4179..8e8f6703 100644 --- a/pkg/config-api-provider/test/resources/service_test_group_assignment_test.go +++ b/pkg/config-api-provider/test/resources/service_test_group_assignment_test.go @@ -56,7 +56,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { } resource "uxi_service_test" "my_service_test" { - title = "title" + name = "name" } import { @@ -126,7 +126,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { } resource "uxi_service_test" "my_service_test" { - title = "title" + name = "name" } import { @@ -141,7 +141,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { } resource "uxi_service_test" "my_service_test_2" { - title = "title_2" + name = "name_2" } import { @@ -245,7 +245,7 @@ func TestServiceTestGroupAssignmentResource429Handling(t *testing.T) { } resource "uxi_service_test" "my_service_test" { - title = "title" + name = "name" } import { @@ -331,7 +331,7 @@ func TestServiceTestGroupAssignmentResourceHttpErrorHandling(t *testing.T) { } resource "uxi_service_test" "my_service_test" { - title = "title" + name = "name" } import { diff --git a/pkg/config-api-provider/test/resources/wired_network_test.go b/pkg/config-api-provider/test/resources/wired_network_test.go index 33388d2b..0ea1c5bc 100644 --- a/pkg/config-api-provider/test/resources/wired_network_test.go +++ b/pkg/config-api-provider/test/resources/wired_network_test.go @@ -26,7 +26,7 @@ func TestWiredNetworkResource(t *testing.T) { { Config: provider.ProviderConfig + ` resource "uxi_wired_network" "my_wired_network" { - alias = "alias" + name = "name" }`, ExpectError: regexp.MustCompile(`(?s)creating a wired_network is not supported; wired_networks can only be\s*imported`), @@ -42,7 +42,7 @@ func TestWiredNetworkResource(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wired_network" "my_wired_network" { - alias = "alias" + name = "name" } import { @@ -51,7 +51,7 @@ func TestWiredNetworkResource(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("uxi_wired_network.my_wired_network", "alias", "alias"), + resource.TestCheckResourceAttr("uxi_wired_network.my_wired_network", "name", "name"), resource.TestCheckResourceAttr("uxi_wired_network.my_wired_network", "id", "uid"), ), }, @@ -79,7 +79,7 @@ func TestWiredNetworkResource(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wired_network" "my_wired_network" { - alias = "updated_alias" + name = "updated_name" }`, ExpectError: regexp.MustCompile(`(?s)updating a wired_network is not supported; wired_networks can only be updated\s*through the dashboard`), }, @@ -133,7 +133,7 @@ func TestWiredNetworkResourceHttpErrorHandling(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wired_network" "my_wired_network" { - alias = "alias" + name = "name" } import { @@ -156,7 +156,7 @@ func TestWiredNetworkResourceHttpErrorHandling(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wired_network" "my_wired_network" { - alias = "alias" + name = "name" } import { diff --git a/pkg/config-api-provider/test/resources/wireless_network_test.go b/pkg/config-api-provider/test/resources/wireless_network_test.go index 5cc34862..486550f0 100644 --- a/pkg/config-api-provider/test/resources/wireless_network_test.go +++ b/pkg/config-api-provider/test/resources/wireless_network_test.go @@ -26,7 +26,7 @@ func TestWirelessNetworkResource(t *testing.T) { { Config: provider.ProviderConfig + ` resource "uxi_wireless_network" "my_wireless_network" { - alias = "alias" + name = "name" }`, ExpectError: regexp.MustCompile(`(?s)creating a wireless_network is not supported; wireless_networks can only be\s*imported`), @@ -42,7 +42,7 @@ func TestWirelessNetworkResource(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wireless_network" "my_wireless_network" { - alias = "alias" + name = "name" } import { @@ -51,7 +51,7 @@ func TestWirelessNetworkResource(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("uxi_wireless_network.my_wireless_network", "alias", "alias"), + resource.TestCheckResourceAttr("uxi_wireless_network.my_wireless_network", "name", "name"), resource.TestCheckResourceAttr("uxi_wireless_network.my_wireless_network", "id", "uid"), ), }, @@ -79,7 +79,7 @@ func TestWirelessNetworkResource(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wireless_network" "my_wireless_network" { - alias = "updated_alias" + name = "updated_name" }`, ExpectError: regexp.MustCompile(`(?s)updating a wireless_network is not supported; wireless_networks can only be\s*updated through the dashboard`), }, @@ -140,7 +140,7 @@ func TestWirelessNetworkResourceHttpErrorHandling(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wireless_network" "my_wireless_network" { - alias = "alias" + name = "name" } import { @@ -163,7 +163,7 @@ func TestWirelessNetworkResourceHttpErrorHandling(t *testing.T) { }, Config: provider.ProviderConfig + ` resource "uxi_wireless_network" "my_wireless_network" { - alias = "alias" + name = "name" } import { diff --git a/pkg/config-api-provider/test/util/utils.go b/pkg/config-api-provider/test/util/utils.go index ce5294d5..112d0d83 100644 --- a/pkg/config-api-provider/test/util/utils.go +++ b/pkg/config-api-provider/test/util/utils.go @@ -61,7 +61,7 @@ func GenerateServiceTestResponseModel(uid string, postfix string) resources.Serv return resources.ServiceTestResponseModel{ Uid: uid, Category: "external" + postfix, - Title: "title" + postfix, + Name: "name" + postfix, Target: "target" + postfix, Template: "template" + postfix, IsEnabled: true, @@ -71,7 +71,7 @@ func GenerateServiceTestResponseModel(uid string, postfix string) resources.Serv func GenerateWiredNetworkResponse(uid string, postfix string) map[string]interface{} { return map[string]interface{}{ "id": uid, - "name": "alias" + postfix, + "name": "name" + postfix, "createdAt": "2024-09-11T12:00:00.000Z", "updatedAt": "2024-09-11T12:00:00.000Z", "ipVersion": "ip_version" + postfix, @@ -91,7 +91,7 @@ func GenerateWirelessNetworkResponse(uid string, postfix string) map[string]inte "ssid": "ssid" + postfix, "createdAt": "2024-09-11T12:00:00.000Z", "updatedAt": "2024-09-11T12:00:00.000Z", - "name": "alias" + postfix, + "name": "name" + postfix, "ipVersion": "ip_version" + postfix, "security": "security" + postfix, "hidden": false, @@ -140,7 +140,7 @@ func GenerateServiceTestGroupAssignmentResponse(uid string, postfix string) conf } } -// Converts a struct to a map while maintaining the json alias as keys +// Converts a struct to a map while maintaining the json name as keys func StructToMap(obj interface{}) map[string]interface{} { data, _ := json.Marshal(obj) // Convert to a json string