Skip to content

Commit

Permalink
Implement delete Proposition. Finally.
Browse files Browse the repository at this point in the history
  • Loading branch information
loafoe committed Oct 2, 2024
1 parent 207809f commit ab9d1ed
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions iam/propositions_service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package iam

import (
"bytes"
"fmt"
"io"
"net/http"
Expand All @@ -19,6 +20,15 @@ type Proposition struct {
GlobalReferenceID string `json:"globalReferenceId"`
}

// PropositionStatus holds the status of a delete Proposition operation
type PropositionStatus struct {
Schemas []string `json:"schemas"`
ID string `json:"id"`
Status string `json:"status"`
TotalResources int `json:"totalResources"`
Meta *Meta `json:"meta"`
}

func (p *Proposition) validate() error {
if p.Name == "" {
return ErrMissingName
Expand Down Expand Up @@ -119,3 +129,36 @@ func (p *PropositionsService) CreateProposition(prop Proposition) (*Proposition,
}
return p.GetPropositionByID(id)
}

func (p *PropositionsService) DeleteProposition(prop Proposition) (bool, *Response, error) {
req, err := p.client.newRequest(IDM, "DELETE", "authorize/scim/v2/Propositions/"+prop.ID, nil, nil)
if err != nil {
return false, nil, err
}
req.Header.Set("api-version", propositionAPIVersion)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("If-Method", "DELETE")

var deleteResponse bytes.Buffer

resp, err := p.client.do(req, &deleteResponse)
if err != nil {
return false, resp, err
}
return resp.StatusCode() == http.StatusAccepted, resp, nil
}

// DeleteStatus returns the status of a delete operation on an organization
func (p *PropositionsService) DeleteStatus(id string) (*PropositionStatus, *Response, error) {
req, err := p.client.newRequest(IDM, "GET", "authorize/scim/v2/Propositions/"+id+"/deleteStatus", nil, nil)
if err != nil {
return nil, nil, err
}
req.Header.Set("api-version", propositionAPIVersion)
req.Header.Set("Content-Type", "application/json")

var deleteResponse PropositionStatus

resp, err := p.client.do(req, &deleteResponse)
return &deleteResponse, resp, err
}

0 comments on commit ab9d1ed

Please sign in to comment.