Compare commits
4 Commits
v1.8.1
...
gos_tech_1
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a813abfcb | |||
| e7b30fb686 | |||
| cf11855fa3 | |||
| f111787976 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,7 +1,5 @@
|
||||
## Version 1.6.8
|
||||
## Version 1.6.14
|
||||
|
||||
## Feature
|
||||
- Add IDs() methods returning array of uint64 IDs for all List* structs in cloudapi/cloudbroker groups
|
||||
|
||||
## Bugfix
|
||||
- Fix field Audit in CloudBrokerEndpoints model in cloudbroker/apiaccess
|
||||
### Bugfix
|
||||
- Delete tag required from DeleteRequest field Permanently in cloudapi/k8s
|
||||
- Delete tag omitempty from DeleteDisksRequest and DisksDeleteRequest field Permanently in cloudapi/disks and cloudbroker/disks
|
||||
58
client.go
58
client.go
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
@@ -97,22 +96,11 @@ func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, p
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := dc.do(req, ctype)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
// perform request
|
||||
var respBytes []byte
|
||||
respBytes, err = dc.do(req, ctype)
|
||||
|
||||
respBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.New(string(respBytes))
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
return respBytes, err
|
||||
}
|
||||
|
||||
func (dc *DecortClient) getToken(ctx context.Context) error {
|
||||
@@ -149,7 +137,7 @@ func (dc *DecortClient) getToken(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dc *DecortClient) do(req *http.Request, ctype string) (*http.Response, error) {
|
||||
func (dc *DecortClient) do(req *http.Request, ctype string) ([]byte, error) {
|
||||
if ctype != "" {
|
||||
req.Header.Add("Content-Type", ctype)
|
||||
} else {
|
||||
@@ -159,25 +147,27 @@ func (dc *DecortClient) do(req *http.Request, ctype string) (*http.Response, err
|
||||
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
// var resp *http.Response
|
||||
// var err error
|
||||
buf, _ := io.ReadAll(req.Body)
|
||||
// req = req.Clone(req.Context())
|
||||
|
||||
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err := dc.client.Do(req)
|
||||
|
||||
// if err == nil {
|
||||
if resp.StatusCode == 200 {
|
||||
return resp, err
|
||||
buf, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
resp.Body.Close()
|
||||
// }
|
||||
// }
|
||||
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
resp, err := dc.client.Do(req)
|
||||
if err != nil || resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// handle successful request
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode == 200 {
|
||||
return respBytes, nil
|
||||
}
|
||||
|
||||
// handle errors with status code other than 200
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ var (
|
||||
|
||||
sepFieldTypeValues = []string{"int", "str", "bool", "list", "dict"}
|
||||
|
||||
networkPluginValues = []string{"flannel", "weawenet", "calico"}
|
||||
networkPluginValues = []string{"flannel", "weavenet", "calico"}
|
||||
|
||||
strictLooseValues = []string{"strict", "loose"}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
@@ -99,22 +98,11 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := ldc.do(req, ctype)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
// perform request
|
||||
var respBytes []byte
|
||||
respBytes, err = ldc.do(req, ctype)
|
||||
|
||||
respBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.New(string(respBytes))
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
return respBytes, err
|
||||
}
|
||||
|
||||
func (ldc *LegacyDecortClient) getToken(ctx context.Context) error {
|
||||
@@ -148,7 +136,7 @@ func (ldc *LegacyDecortClient) getToken(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) (*http.Response, error) {
|
||||
func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) ([]byte, error) {
|
||||
if ctype != "" {
|
||||
req.Header.Add("Content-Type", ctype)
|
||||
} else {
|
||||
@@ -156,26 +144,31 @@ func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) (*http.Respon
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
// var resp *http.Response
|
||||
// var err error
|
||||
buf, _ := io.ReadAll(req.Body)
|
||||
// req = req.Clone(req.Context())
|
||||
|
||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err := ldc.client.Do(req)
|
||||
|
||||
// if err == nil {
|
||||
if resp.StatusCode == 200 {
|
||||
return resp, err
|
||||
buf, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
resp.Body.Close()
|
||||
// }
|
||||
// }
|
||||
req.Body.Close()
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
resp, err := ldc.client.Do(req)
|
||||
if err != nil || resp == nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
||||
// handle successful request
|
||||
respBytes, err := io.ReadAll(resp.Body)
|
||||
if err!= nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
return respBytes, nil
|
||||
}
|
||||
|
||||
// handle errors with status code other than 200
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func (b BService) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/bservice/delete"
|
||||
url := "/cloudapi/bservice/disable"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -169,6 +169,15 @@ type ItemSnapshot struct {
|
||||
}
|
||||
|
||||
// List of Snapshots
|
||||
type ListInfoSnapshots struct {
|
||||
// Data
|
||||
Data ListSnapshots `json:"data"`
|
||||
|
||||
// EntryCount
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// List of Snapshots inside RecordBasicService
|
||||
type ListSnapshots []ItemSnapshot
|
||||
|
||||
// Main information about Group
|
||||
|
||||
@@ -16,7 +16,7 @@ type SnapshotListRequest struct {
|
||||
}
|
||||
|
||||
// SnapshotList gets list existing snapshots of the Basic Service
|
||||
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) {
|
||||
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListInfoSnapshots, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
@@ -29,12 +29,12 @@ func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (Li
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListSnapshots{}
|
||||
list := ListInfoSnapshots{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ type AffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AffinityRuleAdd add affinity rule
|
||||
|
||||
@@ -38,8 +38,8 @@ type AffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AffinityRuleRemove remove affinity rule
|
||||
|
||||
@@ -38,8 +38,8 @@ type AntiAffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleAdd add anti affinity rule
|
||||
|
||||
@@ -38,8 +38,8 @@ type AntiAffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleRemove remove anti affinity rule
|
||||
|
||||
@@ -20,7 +20,7 @@ type DeleteRequest struct {
|
||||
|
||||
// Whether to completely delete the disk, works only with non attached disks
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
|
||||
// Reason to delete
|
||||
// Required: false
|
||||
|
||||
@@ -20,7 +20,7 @@ type DisksDeleteRequest struct {
|
||||
|
||||
// Whether to completely delete the disks, works only with non attached disks
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
// DeleteDisks deletes multiple disks permanently
|
||||
|
||||
@@ -29,7 +29,7 @@ type CreateRequest struct {
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
|
||||
|
||||
// Network plugin
|
||||
// Must be one of these values: flannel, weawenet, calico
|
||||
// Must be one of these values: flannel, weavenet, calico
|
||||
// Required: true
|
||||
NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"`
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ type DeleteRequest struct {
|
||||
|
||||
// True if cluster is destroyed permanently.
|
||||
// Otherwise it can be restored from Recycle Bin
|
||||
// Required: true
|
||||
Permanently bool `url:"permanently" json:"permanently" validate:"required"`
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
// Delete deletes kubernetes cluster
|
||||
|
||||
@@ -331,9 +331,18 @@ type ItemAffinityGroupComputes struct {
|
||||
// List of affinity groups
|
||||
type ListAffinityGroupsComputes []ItemAffinityGroupComputes
|
||||
|
||||
// Main information about
|
||||
type ItemAffinityGroup struct {
|
||||
ID uint64 `json:"id"`
|
||||
NodeID uint64 `json:"node_id"`
|
||||
}
|
||||
|
||||
// List of affinity group
|
||||
type ListAffinityGroup []ItemAffinityGroup
|
||||
|
||||
type ListAffinityGroups struct {
|
||||
// Data
|
||||
Data []map[string][]uint64 `json:"data"`
|
||||
Data []map[string]ListAffinityGroup `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
|
||||
@@ -40,8 +40,8 @@ type AffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AffinityRuleAdd adds affinity rule
|
||||
|
||||
@@ -38,8 +38,8 @@ type AffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AffinityRuleRemove remove affinity rule
|
||||
|
||||
@@ -38,8 +38,8 @@ type AntiAffinityRuleAddRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleAdd adds anti affinity rule
|
||||
|
||||
@@ -38,8 +38,8 @@ type AntiAffinityRuleRemoveRequest struct {
|
||||
Key string `url:"key" json:"key" validate:"required"`
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
// Required: false
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleRemove removes anti affinity rule
|
||||
|
||||
@@ -20,7 +20,7 @@ type DeleteRequest struct {
|
||||
|
||||
// Whether to completely delete the disk, works only with non attached disks
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
|
||||
// Reason to delete
|
||||
// Required: false
|
||||
|
||||
@@ -20,7 +20,7 @@ type DeleteDisksRequest struct {
|
||||
|
||||
// Whether to completely delete the disks, works only with non attached disks
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
// DeleteDisks deletes multiple disks permanently
|
||||
|
||||
@@ -60,7 +60,7 @@ type CreateRequest struct {
|
||||
MaxWorkerCount uint64 `url:"maxWorkerCount" json:"maxWorkerCount" validate:"required"`
|
||||
|
||||
// Network plugins
|
||||
// Values of slice must be flannel, weawenet or calico
|
||||
// Values of slice must be flannel, weavenet or calico
|
||||
//Required: true
|
||||
NetworkPlugins []string `url:"networkPlugins" json:"networkPlugins" validate:"required,networkPlugins"`
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ type DeleteRequest struct {
|
||||
|
||||
// Delete permanently or not
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
// Delete deletes K8CI by ID
|
||||
|
||||
@@ -29,7 +29,7 @@ type CreateRequest struct {
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
|
||||
|
||||
// Network plugin
|
||||
// Must be one of these values: flunnel, weawenet, calico
|
||||
// Must be one of these values: flannel, weavenet, calico
|
||||
// Required: true
|
||||
NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"`
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ type DeleteRequest struct {
|
||||
// True if cluster is destroyed permanently.
|
||||
// Otherwise it can be restored from recycle bin
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
}
|
||||
|
||||
// Delete deletes kubernetes cluster
|
||||
|
||||
Reference in New Issue
Block a user