Skip to content

Commit

Permalink
Merge pull request #23 from OpenVPN/feature/connector-update
Browse files Browse the repository at this point in the history
Added update method support for connecor API
  • Loading branch information
sahaqaa authored Jul 26, 2024
2 parents 7eb2cc5 + 5dbe5a1 commit 80a9065
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cloudconnexa/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ func (c *ConnectorsService) GetByPage(page int, pageSize int) (ConnectorPageResp
return response, nil
}

func (c *ConnectorsService) Update(connector Connector) (*Connector, error) {
connectorJson, err := json.Marshal(connector)
if err != nil {
return nil, err
}

req, err := http.NewRequest(http.MethodPut, fmt.Sprintf("%s/api/beta/connectors/%s", c.client.BaseURL, connector.Id), bytes.NewBuffer(connectorJson))
if err != nil {
return nil, err
}

body, err := c.client.DoRequest(req)
if err != nil {
return nil, err
}

var conn Connector
err = json.Unmarshal(body, &conn)
if err != nil {
return nil, err
}
return &conn, nil
}

func (c *ConnectorsService) List() ([]Connector, error) {
var allConnectors []Connector
page := 0
Expand Down

0 comments on commit 80a9065

Please sign in to comment.