feat: added functionality for remote update command (#282)
* feat: added functionality for remote update command * refactor: removed extra get request for TLS flag and minor changes to help text * chore: pulled newest changes to openapi and ran make fmt * refactor: shortened conditional statement to one line
This commit is contained in:
@ -57,6 +57,54 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
|
||||
return c.printRemote(printRemoteOpts{remote: &res})
|
||||
}
|
||||
|
||||
type UpdateParams struct {
|
||||
RemoteID string
|
||||
Name string
|
||||
Description string
|
||||
RemoteURL string
|
||||
RemoteAPIToken string
|
||||
RemoteOrgID string
|
||||
AllowInsecureTLS bool
|
||||
TLSFlagIsSet bool
|
||||
}
|
||||
|
||||
func (c Client) Update(ctx context.Context, params *UpdateParams) error {
|
||||
// build request
|
||||
body := api.RemoteConnenctionUpdateRequest{}
|
||||
|
||||
if params.Name != "" {
|
||||
body.SetName(params.Name)
|
||||
}
|
||||
|
||||
if params.Description != "" {
|
||||
body.SetDescription(params.Description)
|
||||
}
|
||||
|
||||
if params.RemoteURL != "" {
|
||||
body.SetRemoteURL(params.RemoteURL)
|
||||
}
|
||||
|
||||
if params.RemoteAPIToken != "" {
|
||||
body.SetRemoteAPIToken(params.RemoteAPIToken)
|
||||
}
|
||||
|
||||
if params.RemoteOrgID != "" {
|
||||
body.SetRemoteOrgID(params.RemoteOrgID)
|
||||
}
|
||||
|
||||
if params.TLSFlagIsSet {
|
||||
body.SetAllowInsecureTLS(params.AllowInsecureTLS)
|
||||
}
|
||||
|
||||
// send patch request
|
||||
res, err := c.PatchRemoteConnectionByID(ctx, params.RemoteID).RemoteConnenctionUpdateRequest(body).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update remote connection %q: %w", params.RemoteID, err)
|
||||
}
|
||||
// print updated remote connection info
|
||||
return c.printRemote(printRemoteOpts{remote: &res})
|
||||
}
|
||||
|
||||
type ListParams struct {
|
||||
Name string
|
||||
OrgID string
|
||||
|
||||
Reference in New Issue
Block a user