diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e8ff4..8c5f669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.3 (March 26, 2024) + +BREAKING CHANGES: +* IDs must be treated as a string so that import works correctly. + ## 0.4.2 (March 25, 2024) BUG FIXES: diff --git a/docs/data-sources/entity.md b/docs/data-sources/entity.md index 9f49e78..b14189a 100644 --- a/docs/data-sources/entity.md +++ b/docs/data-sources/entity.md @@ -34,5 +34,5 @@ output "bluecat_config_id" { ### Read-Only -- `id` (Number) Entity identifier +- `id` (String) Entity identifier - `properties` (String) The properties of the entity as returned by the API (pipe delimited). diff --git a/docs/data-sources/host_record.md b/docs/data-sources/host_record.md index fb51224..6a7e358 100644 --- a/docs/data-sources/host_record.md +++ b/docs/data-sources/host_record.md @@ -33,7 +33,7 @@ output "bluecat_host_addresses" { - `address_ids` (Set of Number) A set of all address ids associated with the host record. - `addresses` (Set of String) A set of all addresses associated with the host record. -- `id` (Number) Entity identifier +- `id` (String) Entity identifier - `name` (String) The short name of the host record. - `parent_id` (Number) The ID of the parent of the host record. - `parent_type` (String) The type of the parent of the host record. diff --git a/docs/data-sources/ip4_address.md b/docs/data-sources/ip4_address.md index 7aebbde..dab1454 100644 --- a/docs/data-sources/ip4_address.md +++ b/docs/data-sources/ip4_address.md @@ -34,7 +34,7 @@ output "bluecat_address_mac" { ### Read-Only - `custom_properties` (Map of String) A map of all custom properties associated with the IPv4 address. -- `id` (Number) IP4 Address identifier +- `id` (String) IP4 Address identifier - `mac_address` (String) The MAC address associated with the IPv4 address. - `name` (String) The name assigned to the IPv4 address. This is not related to DNS. - `properties` (String) The properties of the IPv4 address as returned by the API (pipe delimited). diff --git a/docs/data-sources/ip4_nbr.md b/docs/data-sources/ip4_nbr.md index aae2d85..00909ca 100644 --- a/docs/data-sources/ip4_nbr.md +++ b/docs/data-sources/ip4_nbr.md @@ -44,7 +44,7 @@ output "bluecat_network_name" { - `default_view` (Number) The object id of the default DNS View for the network. - `dns_restrictions` (Set of Number) TODO - `gateway` (String) The gateway of the IPv4 network. -- `id` (Number) Example identifier +- `id` (String) Example identifier - `inherit_allow_duplicate_host` (Boolean) Duplicate host names check is inherited. - `inherit_default_domains` (Boolean) Default domains are inherited. - `inherit_default_view` (Boolean) The default DNS View is inherited. diff --git a/docs/data-sources/ip4_network.md b/docs/data-sources/ip4_network.md index 2c48edf..0893bb4 100644 --- a/docs/data-sources/ip4_network.md +++ b/docs/data-sources/ip4_network.md @@ -28,7 +28,7 @@ Data source to access the attributes of an IPv4 network from a hint based search - `default_view` (Number) The object id of the default DNS View for the network. - `dns_restrictions` (Set of Number) The object ids of the DNS restrictions for the network. - `gateway` (String) The gateway of the IP4Network. -- `id` (Number) The ID assigned to the IP4Network. +- `id` (String) The ID assigned to the IP4Network. - `inherit_allow_duplicate_host` (Boolean) Duplicate host names check is inherited. - `inherit_default_domains` (Boolean) Default domains are inherited. - `inherit_default_view` (Boolean) The default DNS View is inherited. diff --git a/docs/resources/host_record.md b/docs/resources/host_record.md index 29cf12d..88be299 100644 --- a/docs/resources/host_record.md +++ b/docs/resources/host_record.md @@ -45,6 +45,6 @@ output "bluecat_hostname_fqdn" { - `absolute_name` (String) The absolute name (fqdn) of the host record. - `address_ids` (Set of Number) A set of all address ids associated with the host record. -- `id` (Number) Host Record identifier +- `id` (String) Host Record identifier - `properties` (String) The properties of the host record as returned by the API (pipe delimited). - `type` (String) The type of the resource. diff --git a/docs/resources/ip4_address.md b/docs/resources/ip4_address.md index c8b390d..8564b32 100644 --- a/docs/resources/ip4_address.md +++ b/docs/resources/ip4_address.md @@ -44,7 +44,7 @@ output "allocated_address" { - `address` (String) The IPv4 address that was allocated. - `expiry_time` (String) Time that IPv4 address lease expires. -- `id` (Number) IPv4 Address identifier. +- `id` (String) IPv4 Address identifier. - `lease_time` (String) Time that IPv4 address was leased. - `location_inherited` (Boolean) The location is inherited. - `parameter_request_list` (String) Time that IPv4 address lease expires. diff --git a/docs/resources/ip4_network.md b/docs/resources/ip4_network.md index c172c57..5dfae73 100644 --- a/docs/resources/ip4_network.md +++ b/docs/resources/ip4_network.md @@ -54,7 +54,7 @@ output "bluecat_ip4_network_cidr" { ### Read-Only - `cidr` (String) The CIDR address of the IPv4 network. -- `id` (Number) IPv4 Network identifier. +- `id` (String) IPv4 Network identifier. - `location_inherited` (Boolean) The location is inherited. - `properties` (String) The properties of the resource as returned by the API (pipe delimited). - `shared_network` (String) The name of the shared network tag associated with the IP4 Network. diff --git a/internal/provider/data_source_entity.go b/internal/provider/data_source_entity.go index f9d0c40..6860244 100644 --- a/internal/provider/data_source_entity.go +++ b/internal/provider/data_source_entity.go @@ -3,6 +3,7 @@ package provider import ( "context" "fmt" + "strconv" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -27,7 +28,7 @@ type entityDataSource struct { // ExampleDataSourceModel describes the data source data model. type EntityDataSourceModel struct { - Id types.Int64 `tfsdk:"id"` + Id types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` Type types.String `tfsdk:"type"` ParentID types.Int64 `tfsdk:"parent_id"` @@ -44,7 +45,7 @@ func (d *entityDataSource) Schema(ctx context.Context, req datasource.SchemaRequ MarkdownDescription: "Data source to access the attributes of a BlueCat entity.", Attributes: map[string]schema.Attribute{ - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ MarkdownDescription: "Entity identifier", Computed: true, }, @@ -126,7 +127,7 @@ func (d *entityDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - data.Id = types.Int64Value(*entity.Id) + data.Id = types.StringValue(strconv.FormatInt(*entity.Id, 10)) data.Properties = types.StringValue(*entity.Properties) resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) diff --git a/internal/provider/data_source_host_record.go b/internal/provider/data_source_host_record.go index d97dc36..5fd3d38 100644 --- a/internal/provider/data_source_host_record.go +++ b/internal/provider/data_source_host_record.go @@ -26,7 +26,7 @@ type HostRecordDataSource struct { // HostRecordDataSourceModel describes the data source data model. type HostRecordDataSourceModel struct { - ID types.Int64 `tfsdk:"id"` + ID types.String `tfsdk:"id"` AbsoluteName types.String `tfsdk:"absolute_name"` Addresses types.Set `tfsdk:"addresses"` AddressIDs types.Set `tfsdk:"address_ids"` @@ -50,7 +50,7 @@ func (d *HostRecordDataSource) Schema(ctx context.Context, req datasource.Schema MarkdownDescription: "Example data source", Attributes: map[string]schema.Attribute{ - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ MarkdownDescription: "Entity identifier", Computed: true, }, @@ -193,7 +193,7 @@ func (d *HostRecordDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - data.ID = types.Int64Value(*hostRecords.Item[matchLocation].Id) + data.ID = types.StringValue(strconv.FormatInt(*hostRecords.Item[matchLocation].Id, 10)) data.Name = types.StringValue(*hostRecords.Item[matchLocation].Name) data.Properties = types.StringValue(*hostRecords.Item[matchLocation].Properties) data.Type = types.StringValue(*hostRecords.Item[matchLocation].Type) diff --git a/internal/provider/data_source_ip4_address.go b/internal/provider/data_source_ip4_address.go index 22fc5b7..ab87673 100644 --- a/internal/provider/data_source_ip4_address.go +++ b/internal/provider/data_source_ip4_address.go @@ -3,6 +3,7 @@ package provider import ( "context" "fmt" + "strconv" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -24,7 +25,7 @@ type IP4AddressDataSource struct { // IP4AddressDataSourceModel describes the data source data model. type IP4AddressDataSourceModel struct { // These are exposed for a generic entity object in bluecat - ID types.Int64 `tfsdk:"id"` + ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` Type types.String `tfsdk:"type"` Properties types.String `tfsdk:"properties"` @@ -60,7 +61,7 @@ func (d *IP4AddressDataSource) Schema(ctx context.Context, req datasource.Schema MarkdownDescription: "Data source to access the attributes of an IPv4 address.", Attributes: map[string]schema.Attribute{ - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ MarkdownDescription: "IP4 Address identifier", Computed: true, }, @@ -147,7 +148,7 @@ func (d *IP4AddressDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - data.ID = types.Int64PointerValue(ip4Address.Id) + data.ID = types.StringValue(strconv.FormatInt(*ip4Address.Id, 10)) data.Name = types.StringPointerValue(ip4Address.Name) data.Properties = types.StringPointerValue(ip4Address.Properties) data.Type = types.StringPointerValue(ip4Address.Type) diff --git a/internal/provider/data_source_ip4_nbr.go b/internal/provider/data_source_ip4_nbr.go index f2971e2..8a8db65 100644 --- a/internal/provider/data_source_ip4_nbr.go +++ b/internal/provider/data_source_ip4_nbr.go @@ -33,7 +33,7 @@ type IP4NBRDataSource struct { // IP4NBRDataSourceModel describes the data source data model. type IP4NBRDataSourceModel struct { - ID types.Int64 `tfsdk:"id"` + ID types.String `tfsdk:"id"` Address types.String `tfsdk:"address"` ContainerID types.Int64 `tfsdk:"container_id"` Type types.String `tfsdk:"type"` @@ -69,7 +69,7 @@ func (d *IP4NBRDataSource) Schema(ctx context.Context, req datasource.SchemaRequ MarkdownDescription: "Data source to access the attributes of an IPv4 network, IPv4 Block, or DHCPv4 Range from an IPv4 address.", Attributes: map[string]schema.Attribute{ - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ MarkdownDescription: "Example identifier", Computed: true, }, @@ -222,7 +222,7 @@ func (d *IP4NBRDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - data.ID = types.Int64PointerValue(ipRange.Id) + data.ID = types.StringValue(strconv.FormatInt(*ipRange.Id, 10)) data.Name = types.StringPointerValue(ipRange.Name) data.Properties = types.StringPointerValue(ipRange.Properties) data.Type = types.StringPointerValue(ipRange.Type) diff --git a/internal/provider/data_source_ip4_network.go b/internal/provider/data_source_ip4_network.go index 8a89471..87084da 100644 --- a/internal/provider/data_source_ip4_network.go +++ b/internal/provider/data_source_ip4_network.go @@ -3,6 +3,7 @@ package provider import ( "context" "fmt" + "strconv" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -25,7 +26,7 @@ type IP4NetworkDataSource struct { // IP4NetworkDataSourceModel describes the data source data model. type IP4NetworkDataSourceModel struct { // These are exposed for a generic entity object in bluecat - ID types.Int64 `tfsdk:"id"` + ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` Type types.String `tfsdk:"type"` Properties types.String `tfsdk:"properties"` @@ -74,7 +75,7 @@ func (d *IP4NetworkDataSource) Schema(ctx context.Context, req datasource.Schema MarkdownDescription: "Hint to find the IP4Network", Required: true, }, - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ MarkdownDescription: "The ID assigned to the IP4Network.", Computed: true, }, @@ -221,7 +222,7 @@ func (d *IP4NetworkDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - data.ID = types.Int64PointerValue(hintResp.Item[0].Id) + data.ID = types.StringValue(strconv.FormatInt(*hintResp.Item[0].Id, 10)) // GetIP4NetworksByHint doesn't seem to return all properties so use the ID returned by it to call GetEntityById entity, err := client.GetEntityById(*hintResp.Item[0].Id) diff --git a/internal/provider/resource_host_record.go b/internal/provider/resource_host_record.go index 1297303..38a20e9 100644 --- a/internal/provider/resource_host_record.go +++ b/internal/provider/resource_host_record.go @@ -39,7 +39,7 @@ type HostRecordResource struct { // HostRecordResourceModel describes the resource data model. type HostRecordResourceModel struct { // These are exposed for a generic entity object in bluecat - ID types.Int64 `tfsdk:"id"` + ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` Type types.String `tfsdk:"type"` Properties types.String `tfsdk:"properties"` @@ -72,11 +72,11 @@ func (r *HostRecordResource) Schema(ctx context.Context, req resource.SchemaRequ Attributes: map[string]schema.Attribute{ // These are exposed for Entity objects via the API - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ Computed: true, MarkdownDescription: "Host Record identifier", - PlanModifiers: []planmodifier.Int64{ - int64planmodifier.UseStateForUnknown(), + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), }, }, "name": schema.StringAttribute{ @@ -213,9 +213,9 @@ func (r *HostRecordResource) Create(ctx context.Context, req resource.CreateRequ return } - data.ID = types.Int64Value(host) + data.ID = types.StringValue(strconv.FormatInt(host, 10)) - entity, err := client.GetEntityById(data.ID.ValueInt64()) + entity, err := client.GetEntityById(host) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError( @@ -269,7 +269,12 @@ func (r *HostRecordResource) Read(ctx context.Context, req resource.ReadRequest, return } - id := data.ID.ValueInt64() + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } entity, err := client.GetEntityById(id) if err != nil { @@ -365,23 +370,30 @@ func (r *HostRecordResource) Update(ctx context.Context, req resource.UpdateRequ } } + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } + tflog.Debug(ctx, fmt.Sprintf("Attempting to update HostRecord with properties: %s", properties)) update := gobam.APIEntity{ - Id: data.ID.ValueInt64Pointer(), + Id: &id, Name: data.Name.ValueStringPointer(), Properties: &properties, Type: state.Type.ValueStringPointer(), } - err := client.Update(&update) + err = client.Update(&update) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError("Host Record Update failed", err.Error()) return } - entity, err := client.GetEntityById(data.ID.ValueInt64()) + entity, err := client.GetEntityById(id) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError( @@ -431,7 +443,12 @@ func (r *HostRecordResource) Delete(ctx context.Context, req resource.DeleteRequ return } - id := data.ID.ValueInt64() + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } entity, err := client.GetEntityById(id) if err != nil { diff --git a/internal/provider/resource_ip4_address.go b/internal/provider/resource_ip4_address.go index 232e670..8f6ce98 100644 --- a/internal/provider/resource_ip4_address.go +++ b/internal/provider/resource_ip4_address.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "slices" + "strconv" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" @@ -38,7 +39,7 @@ type IP4AddressResource struct { // IP4AddressResourceModel describes the resource data model. type IP4AddressResourceModel struct { // These are exposed for a generic entity object in bluecat - ID types.Int64 `tfsdk:"id"` + ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` Type types.String `tfsdk:"type"` Properties types.String `tfsdk:"properties"` @@ -77,11 +78,11 @@ func (r *IP4AddressResource) Schema(ctx context.Context, req resource.SchemaRequ Attributes: map[string]schema.Attribute{ // These are exposed for Entity objects via the API - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ MarkdownDescription: "IPv4 Address identifier.", Computed: true, - PlanModifiers: []planmodifier.Int64{ - int64planmodifier.UseStateForUnknown(), + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), }, }, "name": schema.StringAttribute{ @@ -249,9 +250,9 @@ func (r *IP4AddressResource) Create(ctx context.Context, req resource.CreateRequ return } - data.ID = types.Int64PointerValue(ip.Id) + data.ID = types.StringValue(strconv.FormatInt(*ip.Id, 10)) - entity, err := client.GetEntityById(data.ID.ValueInt64()) + entity, err := client.GetEntityById(*ip.Id) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError( @@ -310,7 +311,14 @@ func (r *IP4AddressResource) Read(ctx context.Context, req resource.ReadRequest, return } - entity, err := client.GetEntityById(data.ID.ValueInt64()) + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } + + entity, err := client.GetEntityById(id) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError("Failed to get IP4 Address by Id", err.Error()) @@ -400,21 +408,28 @@ func (r *IP4AddressResource) Update(ctx context.Context, req resource.UpdateRequ } } + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } + update := gobam.APIEntity{ - Id: data.ID.ValueInt64Pointer(), + Id: &id, Name: data.Name.ValueStringPointer(), Properties: &properties, Type: state.Type.ValueStringPointer(), } - err := client.Update(&update) + err = client.Update(&update) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError("Failed to update IP4 Address", err.Error()) return } - entity, err := client.GetEntityById(data.ID.ValueInt64()) + entity, err := client.GetEntityById(id) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError( @@ -471,9 +486,14 @@ func (r *IP4AddressResource) Delete(ctx context.Context, req resource.DeleteRequ return } - id := data.ID.ValueInt64() + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } - err := client.Delete(id) + err = client.Delete(id) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError("Failed to delete IP4 Address", err.Error()) diff --git a/internal/provider/resource_ip4_network.go b/internal/provider/resource_ip4_network.go index b962b80..3a2e30f 100644 --- a/internal/provider/resource_ip4_network.go +++ b/internal/provider/resource_ip4_network.go @@ -43,7 +43,7 @@ type IP4NetworkResource struct { // IP4NetworkResourceModel describes the resource data model. type IP4NetworkResourceModel struct { // These are exposed for a generic entity object in bluecat - ID types.Int64 `tfsdk:"id"` + ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` Type types.String `tfsdk:"type"` Properties types.String `tfsdk:"properties"` @@ -87,11 +87,11 @@ func (r *IP4NetworkResource) Schema(ctx context.Context, req resource.SchemaRequ Attributes: map[string]schema.Attribute{ // These are exposed for Entity objects via the API - "id": schema.Int64Attribute{ + "id": schema.StringAttribute{ MarkdownDescription: "IPv4 Network identifier.", Computed: true, - PlanModifiers: []planmodifier.Int64{ - int64planmodifier.UseStateForUnknown(), + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), }, }, "name": schema.StringAttribute{ @@ -309,7 +309,7 @@ func (r *IP4NetworkResource) Create(ctx context.Context, req resource.CreateRequ return } - data.ID = types.Int64PointerValue(network.Id) + data.ID = types.StringValue(strconv.FormatInt(*network.Id, 10)) data.Properties = types.StringPointerValue(network.Properties) data.Type = types.StringPointerValue(network.Type) @@ -377,7 +377,7 @@ func (r *IP4NetworkResource) Create(ctx context.Context, req resource.CreateRequ } setName := gobam.APIEntity{ - Id: data.ID.ValueInt64Pointer(), + Id: network.Id, Name: data.Name.ValueStringPointer(), Properties: &properties, Type: data.Type.ValueStringPointer(), @@ -394,7 +394,7 @@ func (r *IP4NetworkResource) Create(ctx context.Context, req resource.CreateRequ return } - entity, err := client.GetEntityById(data.ID.ValueInt64()) + entity, err := client.GetEntityById(*network.Id) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError( @@ -459,7 +459,12 @@ func (r *IP4NetworkResource) Read(ctx context.Context, req resource.ReadRequest, return } - id := data.ID.ValueInt64() + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } entity, err := client.GetEntityById(id) if err != nil { @@ -614,8 +619,15 @@ func (r *IP4NetworkResource) Update(ctx context.Context, req resource.UpdateRequ } } + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } + update := gobam.APIEntity{ - Id: state.ID.ValueInt64Pointer(), + Id: &id, Name: data.Name.ValueStringPointer(), Properties: &properties, Type: state.Type.ValueStringPointer(), @@ -623,7 +635,7 @@ func (r *IP4NetworkResource) Update(ctx context.Context, req resource.UpdateRequ tflog.Debug(ctx, fmt.Sprintf("Attempting to update IP4Network with properties: %s", properties)) - err := client.Update(&update) + err = client.Update(&update) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError( @@ -633,7 +645,7 @@ func (r *IP4NetworkResource) Update(ctx context.Context, req resource.UpdateRequ return } - entity, err := client.GetEntityById(data.ID.ValueInt64()) + entity, err := client.GetEntityById(id) if err != nil { resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) resp.Diagnostics.AddError( @@ -695,7 +707,12 @@ func (r *IP4NetworkResource) Delete(ctx context.Context, req resource.DeleteRequ return } - id := data.ID.ValueInt64() + id, err := strconv.ParseInt(data.ID.ValueString(), 10, 64) + if err != nil { + resp.Diagnostics.Append(clientLogout(ctx, &client, mutex)...) + resp.Diagnostics.AddError("Failed to parse ID", err.Error()) + return + } entity, err := client.GetEntityById(id) if err != nil {