diff --git a/GNUmakefile b/GNUmakefile index bc0a8d1..3bfd890 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ HOSTNAME=github.com NAMESPACE=nleiva NAME=nautobot BINARY=terraform-provider-${NAME} -VERSION=0.1.0 +VERSION=0.2.0 OS_ARCH=$(shell go env GOOS)_$(shell go env GOARCH) diff --git a/README.md b/README.md index cc461ed..e525e6f 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Then commit the changes to `go.mod` and `go.sum`. ## Using the provider -The provide takes two arguments, `url` and `token`. For the data sources and resources supported, take a look at the [internal/provider](internal/provider) folder. In the next example, we capture the data of all manufacturers. +The provide takes two arguments, `url` and `token`. For the data sources and resources supported, take a look at the [internal/provider](internal/provider) folder. In the next example, we capture the data of all manufacturers and create a new manufacturer "Vendor I". ```hcl diff --git a/internal/provider/resource_manufacturer.go b/internal/provider/resource_manufacturer.go index d7a9d56..4d056e1 100644 --- a/internal/provider/resource_manufacturer.go +++ b/internal/provider/resource_manufacturer.go @@ -262,5 +262,22 @@ func resourceManufacturerUpdate(ctx context.Context, d *schema.ResourceData, met func resourceManufacturerDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics + c := meta.(*apiClient).Client + s := meta.(*apiClient).Server + + id := d.Get("id").(string) + name := d.Get("name").(string) + + _, err := c.DcimManufacturersDestroy( + ctx, + types.UUID(id)) + if err != nil { + return diag.Errorf("failed to delete manufacturer %s on %s: %s", name, s, err.Error()) + } + + // d.SetId("") is automatically called assuming delete returns no errors, but + // it is added here for explicitness. + d.SetId("") + return diags }