/
get_thread_dump_operation.go
88 lines (71 loc) · 2.22 KB
/
get_thread_dump_operation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Code generated by go-swagger;
package cli
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"github.com/umutbasal/antmedia/client/operations"
"github.com/go-openapi/swag"
"github.com/spf13/cobra"
)
// makeOperationOperationsGetThreadDumpCmd returns a cmd to handle operation getThreadDump
func makeOperationOperationsGetThreadDumpCmd() (*cobra.Command, error) {
cmd := &cobra.Command{
Use: "getThreadDump",
Short: ``,
RunE: runOperationOperationsGetThreadDump,
}
if err := registerOperationOperationsGetThreadDumpParamFlags(cmd); err != nil {
return nil, err
}
return cmd, nil
}
// runOperationOperationsGetThreadDump uses cmd flags to call endpoint api
func runOperationOperationsGetThreadDump(cmd *cobra.Command, args []string) error {
appCli, err := makeClient(cmd, args)
if err != nil {
return err
}
// retrieve flag values from cmd and fill params
params := operations.NewGetThreadDumpParams()
if dryRun {
logDebugf("dry-run flag specified. Skip sending request.")
return nil
}
// make request and then print result
msgStr, err := parseOperationOperationsGetThreadDumpResult(appCli.Operations.GetThreadDump(params))
if err != nil {
return err
}
if !debug {
fmt.Println(msgStr)
}
return nil
}
// registerOperationOperationsGetThreadDumpParamFlags registers all flags needed to fill params
func registerOperationOperationsGetThreadDumpParamFlags(cmd *cobra.Command) error {
return nil
}
// parseOperationOperationsGetThreadDumpResult parses request result and return the string content
func parseOperationOperationsGetThreadDumpResult(resp0 *operations.GetThreadDumpOK, respErr error) (string, error) {
if respErr != nil {
var iResp0 interface{} = respErr
resp0, ok := iResp0.(*operations.GetThreadDumpOK)
if ok {
if !swag.IsZero(resp0) && !swag.IsZero(resp0.Payload) {
msgStr, err := json.Marshal(resp0.Payload)
if err != nil {
return "", err
}
return string(msgStr), nil
}
}
return "", respErr
}
if !swag.IsZero(resp0) && !swag.IsZero(resp0.Payload) {
msgStr := fmt.Sprintf("%v", resp0.Payload)
return string(msgStr), nil
}
return "", nil
}