Add delete manufaturer
parent
5d335e6e18
commit
008973b1f3
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue