Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 458 2 #493

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewCreateCommand(parentCmd *cobra.Command) func() {
return err
}

err = json.PrintJson(string(outputJson))
err = json.PrintJsonToStdout(string(outputJson))

if err != nil {
return err
Expand All @@ -146,7 +146,7 @@ func NewCreateCommand(parentCmd *cobra.Command) func() {
}
}

return json.PrintJson(body)
return json.PrintJsonToStdout(body)
}

}
Expand Down Expand Up @@ -343,7 +343,7 @@ func createInternal(ctx context.Context, overrides *httpclient.HttpParameterOver

// Check if error response
if resp.StatusCode >= 400 && resp.StatusCode <= 600 {
json.PrintJson(string(resBody))
json.PrintJsonToStdout(string(resBody))
return "", fmt.Errorf(resp.Status)
}

Expand Down
14 changes: 13 additions & 1 deletion cmd/delete-all.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,19 @@ func deleteAllInternal(ctx context.Context, args []string) error {
return err
}

ids, totalCount, err := apihelper.GetResourceIdsFromHttpResponse(resp)
if resp.StatusCode >= 400 {
log.Warnf("Could not retrieve page of data, aborting")
break
}

bodyTxt, err := io.ReadAll(resp.Body)

if err != nil {
return err
}

ids, totalCount, err := apihelper.GetResourceIdsFromHttpResponse(bodyTxt)

resp.Body.Close()

allIds := make([][]id.IdableAttributes, 0)
Expand Down
4 changes: 2 additions & 2 deletions cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func NewDeleteCommand(parentCmd *cobra.Command) func() {
if err != nil {
if body != "" {
if !noBodyPrint {
json.PrintJson(body)
json.PrintJsonToStdout(body)
}
}
return err
Expand All @@ -108,7 +108,7 @@ func NewDeleteCommand(parentCmd *cobra.Command) func() {
if noBodyPrint {
return nil
} else {
return json.PrintJson(body)
return json.PrintJsonToStdout(body)
}
}

Expand Down
Loading
Loading