/
support_bundle_download.go
101 lines (76 loc) · 3.17 KB
/
support_bundle_download.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
89
90
91
92
93
94
95
96
97
98
99
100
101
package isegosdk
import (
"fmt"
"strings"
"github.com/go-resty/resty/v2"
)
type SupportBundleDownloadService service
type ResponseSupportBundleDownloadGetVersion struct {
VersionInfo *ResponseSupportBundleDownloadGetVersionVersionInfo `json:"VersionInfo,omitempty"` //
}
type ResponseSupportBundleDownloadGetVersionVersionInfo struct {
CurrentServerVersion string `json:"currentServerVersion,omitempty"` //
SupportedVersions string `json:"supportedVersions,omitempty"` //
Link *ResponseSupportBundleDownloadGetVersionVersionInfoLink `json:"link,omitempty"` //
}
type ResponseSupportBundleDownloadGetVersionVersionInfoLink struct {
Rel string `json:"rel,omitempty"` //
Href string `json:"href,omitempty"` //
Type string `json:"type,omitempty"` //
}
type RequestSupportBundleDownloadDownloadSupportBundle struct {
ErsSupportBundleDownload *RequestSupportBundleDownloadDownloadSupportBundleErsSupportBundleDownload `json:"ErsSupportBundleDownload,omitempty"` //
}
type RequestSupportBundleDownloadDownloadSupportBundleErsSupportBundleDownload struct {
FileName string `json:"fileName,omitempty"` //
}
//GetVersion Get support bundle download version information
/* This API helps to retrieve the version information related to the support bundle download.
*/
func (s *SupportBundleDownloadService) GetVersion() (*ResponseSupportBundleDownloadGetVersion, *resty.Response, error) {
setHost(s.client, "_ers")
path := "/ers/config/supportbundledownload/versioninfo"
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseSupportBundleDownloadGetVersion{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetVersion")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseSupportBundleDownloadGetVersion)
return result, response, err
}
//DownloadSupportBundle Upload support bundle
/* This API allows the client to upload a support bundle.
*/
func (s *SupportBundleDownloadService) DownloadSupportBundle(requestSupportBundleDownloadDownloadSupportBundle *RequestSupportBundleDownloadDownloadSupportBundle) (FileDownload, *resty.Response, error) {
setHost(s.client, "_ers")
path := "/ers/config/supportbundledownload"
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetBody(requestSupportBundleDownloadDownloadSupportBundle).
SetError(&Error).
Put(path)
fdownload := FileDownload{}
if err != nil {
return fdownload, nil, err
}
if response.IsError() {
return fdownload, response, fmt.Errorf("error with operation ExportTrustedCertificate")
}
fdownload.FileData = response.Body()
headerVal := response.Header()["Content-Disposition"][0]
fname := strings.SplitAfter(headerVal, "=")
fdownload.FileName = strings.ReplaceAll(fname[1], "\"", "")
getCSFRToken(response.Header())
return fdownload, response, err
}