forked from equinix/ne-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest_licensefile.go
28 lines (25 loc) · 898 Bytes
/
rest_licensefile.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
package ne
import (
"io"
"net/http"
"github.com/equinix/ne-go/internal/api"
)
//UploadLicenseFile performs multipart upload of a license file from a given reader interface
//along with provided data. Uploaded file identifier is returned on success.
func (c RestClient) UploadLicenseFile(metroCode, deviceTypeCode, deviceManagementMode, licenseMode, fileName string, reader io.Reader) (*string, error) {
path := "/ne/v1/devices/licenseFiles"
respBody := api.LicenseFileUploadResponse{}
req := c.R().
SetFileReader("file", fileName, reader).
SetFormData(map[string]string{
"metroCode": metroCode,
"deviceTypeCode": deviceTypeCode,
"licenseType": licenseMode,
"deviceManagementType": deviceManagementMode,
}).
SetResult(&respBody)
if err := c.Execute(req, http.MethodPost, path); err != nil {
return nil, err
}
return respBody.FileID, nil
}