Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit ab9d1ed

Browse files
committed
Implement delete Proposition. Finally.
1 parent 207809f commit ab9d1ed

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

iam/propositions_service.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package iam
22

33
import (
4+
"bytes"
45
"fmt"
56
"io"
67
"net/http"
@@ -19,6 +20,15 @@ type Proposition struct {
1920
GlobalReferenceID string `json:"globalReferenceId"`
2021
}
2122

23+
// PropositionStatus holds the status of a delete Proposition operation
24+
type PropositionStatus struct {
25+
Schemas []string `json:"schemas"`
26+
ID string `json:"id"`
27+
Status string `json:"status"`
28+
TotalResources int `json:"totalResources"`
29+
Meta *Meta `json:"meta"`
30+
}
31+
2232
func (p *Proposition) validate() error {
2333
if p.Name == "" {
2434
return ErrMissingName
@@ -119,3 +129,36 @@ func (p *PropositionsService) CreateProposition(prop Proposition) (*Proposition,
119129
}
120130
return p.GetPropositionByID(id)
121131
}
132+
133+
func (p *PropositionsService) DeleteProposition(prop Proposition) (bool, *Response, error) {
134+
req, err := p.client.newRequest(IDM, "DELETE", "authorize/scim/v2/Propositions/"+prop.ID, nil, nil)
135+
if err != nil {
136+
return false, nil, err
137+
}
138+
req.Header.Set("api-version", propositionAPIVersion)
139+
req.Header.Set("Content-Type", "application/json")
140+
req.Header.Set("If-Method", "DELETE")
141+
142+
var deleteResponse bytes.Buffer
143+
144+
resp, err := p.client.do(req, &deleteResponse)
145+
if err != nil {
146+
return false, resp, err
147+
}
148+
return resp.StatusCode() == http.StatusAccepted, resp, nil
149+
}
150+
151+
// DeleteStatus returns the status of a delete operation on an organization
152+
func (p *PropositionsService) DeleteStatus(id string) (*PropositionStatus, *Response, error) {
153+
req, err := p.client.newRequest(IDM, "GET", "authorize/scim/v2/Propositions/"+id+"/deleteStatus", nil, nil)
154+
if err != nil {
155+
return nil, nil, err
156+
}
157+
req.Header.Set("api-version", propositionAPIVersion)
158+
req.Header.Set("Content-Type", "application/json")
159+
160+
var deleteResponse PropositionStatus
161+
162+
resp, err := p.client.do(req, &deleteResponse)
163+
return &deleteResponse, resp, err
164+
}

0 commit comments

Comments
 (0)