Skip to content

Commit

Permalink
feat: tag delete (#521)
Browse files Browse the repository at this point in the history
* feat: resource tag create

* fix: lint errors

* fix: lint errors

* refactor: refactor tag client

* feat: tag update

* refactor: refactor tag client

* feat: changed tag description

* feat: tag import

* feat: lint error

* feat: tag delete
  • Loading branch information
wai-wong-edb authored Aug 14, 2024
1 parent 791f044 commit 0e10501
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/api/tag_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,14 @@ func (tc TagClient) List(ctx context.Context) ([]api.TagResponse, error) {

return response.Data, err
}

func (tc TagClient) Delete(ctx context.Context, tagId string) error {
url := fmt.Sprintf("tags/%s", tagId)

_, err := tc.doRequest(ctx, http.MethodDelete, url, nil)
if err != nil {
return err
}

return nil
}
14 changes: 14 additions & 0 deletions pkg/provider/resource_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ func (tr *tagResource) Update(ctx context.Context, req resource.UpdateRequest, r
}

func (tr *tagResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var state TagResourceModel
diags := req.State.Get(ctx, &state)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}

err := tr.client.Delete(ctx, state.TagId.ValueString())
if err != nil {
if !appendDiagFromBAErr(err, &resp.Diagnostics) {
resp.Diagnostics.AddError("Error deleting tag", err.Error())
}
return
}
}

func (tr *tagResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
Expand Down

0 comments on commit 0e10501

Please sign in to comment.