Add delete manufaturer

main
nleiva 2022-04-28 12:36:40 -04:00
parent 5d335e6e18
commit 008973b1f3
3 changed files with 19 additions and 2 deletions

View File

@ -3,7 +3,7 @@ HOSTNAME=github.com
NAMESPACE=nleiva NAMESPACE=nleiva
NAME=nautobot NAME=nautobot
BINARY=terraform-provider-${NAME} BINARY=terraform-provider-${NAME}
VERSION=0.1.0 VERSION=0.2.0
OS_ARCH=$(shell go env GOOS)_$(shell go env GOARCH) OS_ARCH=$(shell go env GOOS)_$(shell go env GOARCH)

View File

@ -31,7 +31,7 @@ Then commit the changes to `go.mod` and `go.sum`.
## Using the provider ## 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 ```hcl

View File

@ -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 { func resourceManufacturerDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags 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 return diags
} }