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:
mcfarlm3
2021-10-04 10:28:07 -07:00
committed by GitHub
parent b7627a33c8
commit 3c3d70cc60
2 changed files with 99 additions and 3 deletions

View File

@ -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