forked from f5devcentral/go-bigip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shared.go
61 lines (53 loc) · 1.63 KB
/
shared.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
package bigip
import (
"bytes"
"fmt"
"os"
"strings"
)
const (
uriShared = "shared"
uriLicensing = "licensing"
uriActivation = "activation"
uriRegistration = "registration"
uriFileTransfer = "file-transfer"
uriUploads = "uploads"
activationComplete = "LICENSING_COMPLETE"
activationInProgress = "LICENSING_ACTIVATION_IN_PROGRESS"
activationFailed = "LICENSING_FAILED"
activationNeedEula = "NEED_EULA_ACCEPT"
)
// Installs the given license.
func (b *BigIP) InstallLicense(licenseText string) error {
r := map[string]string{"licenseText": licenseText}
return b.put(r, uriShared, uriLicensing, uriRegistration)
}
// Revoke license.
func (b *BigIP) RevokeLicense() error {
//r := map[string]string{"licenseText": licenseText}
return b.delete(uriShared, uriLicensing, uriRegistration)
}
// Upload a file
func (b *BigIP) UploadFile(f *os.File) (*Upload, error) {
if strings.HasSuffix(f.Name(), ".iso") {
err := fmt.Errorf("File must not have .iso extension")
return nil, err
}
info, err := f.Stat()
if err != nil {
return nil, err
}
return b.Upload(f, info.Size(), uriShared, uriFileTransfer, uriUploads, info.Name())
}
// Upload a file from a byte slice
func (b *BigIP) UploadBytes(data []byte, filename string) (*Upload, error) {
r := bytes.NewReader(data)
size := int64(len(data))
return b.Upload(r, size, uriShared, uriFileTransfer, uriUploads, filename)
}
// Upload a file from a byte slice
func (b *BigIP) UploadAsmBytes(data []byte, filename string) (*Upload, error) {
r := bytes.NewReader(data)
size := int64(len(data))
return b.Upload(r, size, uriTm, uriAsm, uriFileTransfer, uriUploads, filename)
}