Skip to content

Commit 8e806b7

Browse files
Ensure the output of the api sub command goes to stdout, fix patch content-type
1 parent 7864488 commit 8e806b7

File tree

7 files changed

+13
-17
lines changed

7 files changed

+13
-17
lines changed

cmd/api/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func newDeleteCmd() *cobra.Command {
9898
}
9999

100100
if jsonPath != "" {
101-
cmd.Print(string(responseBody))
101+
fmt.Fprint(cmd.OutOrStdout(), string(responseBody))
102102
} else {
103103
cmd.Println(string(responseBody))
104104
fmt.Printf("Status: %s\n", resp.Status)

cmd/api/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func newGetCmd() *cobra.Command {
120120
}
121121

122122
if jsonPath != "" {
123-
cmd.Print(string(body))
123+
fmt.Fprint(cmd.OutOrStdout(), string(body))
124124
} else {
125125
cmd.Println(string(body))
126126
fmt.Printf("Status: %s\n", resp.Status)

cmd/api/patch.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ func newPatchCmd() *cobra.Command {
6666
return fmt.Errorf("either --body or --body-file must be provided")
6767
}
6868

69+
// Prepare headers
70+
headers := make(map[string]string)
71+
6972
if contentType == "" {
70-
contentType = "application/json"
73+
contentType = "application/json-patch+json"
7174
}
7275

73-
// Prepare headers
74-
headers := make(map[string]string)
76+
headers["Content-Type"] = contentType
7577
// Always add Accept header for JSON
7678
headers["Accept"] = "application/json"
7779
// Add any additional headers
@@ -126,10 +128,10 @@ func newPatchCmd() *cobra.Command {
126128
}
127129
fmt.Printf("Response saved to %s\n", outputFile)
128130
} else {
129-
cmd.Println(string(responseBody))
131+
fmt.Fprint(cmd.OutOrStdout(), string(responseBody))
130132
}
131133

132-
fmt.Printf("Status: %s\n", resp.Status)
134+
fmt.Printf("\nStatus: %s\n", resp.Status)
133135
return nil
134136
},
135137
}
@@ -139,7 +141,7 @@ func newPatchCmd() *cobra.Command {
139141
cmd.Flags().StringVarP(&bodyContent, "body", "b", "", "Request body content as a string")
140142
cmd.Flags().StringVarP(&outputFile, "output", "o", "", "Output file to save the response (if not specified, prints to stdout)")
141143
cmd.Flags().BoolVarP(&prettyPrint, "pretty", "p", false, "Pretty print JSON response")
142-
cmd.Flags().StringVarP(&contentType, "content-type", "c", "application/json", "Content type of the request body")
144+
cmd.Flags().StringVarP(&contentType, "content-type", "c", "", "Content type of the request body")
143145
cmd.Flags().StringVarP(&jsonPath, "jsonpath", "j", "", "JSONPath expression to evaluate on the response")
144146

145147
return cmd

cmd/api/post.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func newPostCmd() *cobra.Command {
119119
}
120120

121121
if jsonPath != "" {
122-
cmd.Print(string(responseBody))
122+
fmt.Fprint(cmd.OutOrStdout(), string(responseBody))
123123
} else {
124124
cmd.Println(string(responseBody))
125125
fmt.Printf("Status: %s\n", resp.Status)

cmd/api/put.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func newPutCmd() *cobra.Command {
119119
}
120120

121121
if jsonPath != "" {
122-
cmd.Print(string(responseBody))
122+
fmt.Fprint(cmd.OutOrStdout(), string(responseBody))
123123
} else {
124124
cmd.Println(string(responseBody))
125125
fmt.Printf("Status: %s\n", resp.Status)

cmd/reassign/reassign.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ You can reassign ownership for the following supported object types:
1818

1919
==Example==
2020

21-
Use this command to interactively choose the identities and object types you wish to reassign.
22-
23-
```bash
24-
sail reassign
25-
```
26-
2721
Reassign all objects from one identity to another
2822

2923
```bash

cmd/rule/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func newListCommand() *cobra.Command {
2323

2424
var description = string("Export of all rules")
2525
var objectOptions string
26-
var includeTypes = []string{"RULE"}
26+
var includeTypes = []string{"RULE", "CONNECTOR_RULE"}
2727
var excludeTypes []string
2828

2929
var cloud bool

0 commit comments

Comments
 (0)