diff options
author | Julien Dessaux | 2023-09-24 01:23:50 +0200 |
---|---|---|
committer | Julien Dessaux | 2023-09-24 01:23:50 +0200 |
commit | 4f77442eff59061ac5ab9f710fdb6fe998fedb5f (patch) | |
tree | 79fc8205bdbcebd9c805ed5c4a229affa0b3fdff /external/evcli | |
parent | Updated dependencies (diff) | |
download | terraform-provider-eventline-4f77442eff59061ac5ab9f710fdb6fe998fedb5f.tar.gz terraform-provider-eventline-4f77442eff59061ac5ab9f710fdb6fe998fedb5f.tar.bz2 terraform-provider-eventline-4f77442eff59061ac5ab9f710fdb6fe998fedb5f.zip |
Add identity resource
Diffstat (limited to '')
-rw-r--r-- | external/evcli/client.go | 31 | ||||
-rw-r--r-- | external/evcli/identities.go | 28 |
2 files changed, 31 insertions, 28 deletions
diff --git a/external/evcli/client.go b/external/evcli/client.go index 769c19c..3720115 100644 --- a/external/evcli/client.go +++ b/external/evcli/client.go @@ -181,6 +181,12 @@ func (c *Client) UpdateProject(project *eventline.Project) error { return c.SendRequest("PUT", uri, project, nil) } +func (c *Client) CreateIdentity(identity *Identity) error { + uri := NewURL("identities") + + return c.SendRequest("POST", uri, identity, identity) +} + func (c *Client) FetchIdentities() (Identities, error) { var identities Identities @@ -209,6 +215,31 @@ func (c *Client) FetchIdentities() (Identities, error) { return identities, nil } +func (c *Client) FetchIdentityById(id eventline.Id) (*Identity, error) { + uri := NewURL("identities", "id", id.String()) + + var identity Identity + + err := c.SendRequest("GET", uri, nil, &identity) + if err != nil { + return nil, err + } + + return &identity, nil +} + +func (c *Client) UpdateIdentity(identity *Identity) error { + uri := NewURL("identities", "id", identity.Id.String()) + + return c.SendRequest("PUT", uri, identity, identity) +} + +func (c *Client) DeleteIdentity(id eventline.Id) error { + uri := NewURL("identities", "id", id.String()) + + return c.SendRequest("DELETE", uri, nil, nil) +} + func (c *Client) ReplayEvent(id string) (*eventline.Event, error) { var event eventline.Event diff --git a/external/evcli/identities.go b/external/evcli/identities.go index f89ae1b..a2c2549 100644 --- a/external/evcli/identities.go +++ b/external/evcli/identities.go @@ -2,7 +2,6 @@ package evcli import ( "encoding/json" - "fmt" "time" "github.com/exograd/eventline/pkg/eventline" @@ -27,7 +26,6 @@ type Identity struct { RefreshTime *time.Time `json:"refresh_time,omitempty"` Connector string `json:"connector"` Type string `json:"type"` - Data eventline.IdentityData `json:"-"` RawData json.RawMessage `json:"data"` } @@ -45,29 +43,3 @@ func (i *Identity) SortKey(sort string) (key string) { return } - -func (pi *Identity) MarshalJSON() ([]byte, error) { - type Identity2 Identity - - i := Identity2(*pi) - data, err := json.Marshal(i.Data) - if err != nil { - return nil, fmt.Errorf("cannot encode data: %w", err) - } - - i.RawData = data - - return json.Marshal(i) -} - -func (pi *Identity) UnmarshalJSON(data []byte) error { - type Identity2 Identity - - i := Identity2(*pi) - if err := json.Unmarshal(data, &i); err != nil { - return err - } - - *pi = Identity(i) - return nil -} |