v1.15.0
This commit is contained in:
51
pkg/cloudbroker/zone/add_cpu_alignment_profile.go
Normal file
51
pkg/cloudbroker/zone/add_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AddCPUAlignmentProfileRequest struct to add CPU alignment profile to zone
|
||||
type AddCPUAlignmentProfileRequest struct {
|
||||
// ID of zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// Hypervisor similarity in percentage
|
||||
// Default: 70
|
||||
// Required: false
|
||||
HypervisorSimilarityInPercentage uint64 `url:"hypervisor_similarity_in_percentage,omitempty" json:"hypervisor_similarity_in_percentage,omitempty"`
|
||||
}
|
||||
|
||||
// AddCPUAlignmentProfile adds CPU alignment profile to zone
|
||||
func (e Zone) AddCPUAlignmentProfile(ctx context.Context, req AddCPUAlignmentProfileRequest) ([]CpuAlignmentProfile, error) {
|
||||
res, err := e.AddCPUAlignmentProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var profiles []CpuAlignmentProfile
|
||||
|
||||
err = json.Unmarshal(res, &profiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
// AddCPUAlignmentProfileRaw adds CPU alignment profile to zone and returns the result as an array of bytes
|
||||
func (e Zone) AddCPUAlignmentProfileRaw(ctx context.Context, req AddCPUAlignmentProfileRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/add_cpu_alignment_profile"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
38
pkg/cloudbroker/zone/delete_cpu_alignment_profile.go
Normal file
38
pkg/cloudbroker/zone/delete_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteCPUAlignmentProfileRequest struct to delete CPU alignment profile from zone
|
||||
type DeleteCPUAlignmentProfileRequest struct {
|
||||
// ID of zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
}
|
||||
|
||||
// DeleteCPUAlignmentProfile deletes CPU alignment profile from zone
|
||||
func (e Zone) DeleteCPUAlignmentProfile(ctx context.Context, req DeleteCPUAlignmentProfileRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/delete_cpu_alignment_profile"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/zone/get_cpu_alignment_profile.go
Normal file
46
pkg/cloudbroker/zone/get_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetCPUAlignmentProfileRequest struct to get CPU alignment profile of zone
|
||||
type GetCPUAlignmentProfileRequest struct {
|
||||
// ID of zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetCPUAlignmentProfile gets CPU alignment profile of zone
|
||||
func (e Zone) GetCPUAlignmentProfile(ctx context.Context, req GetCPUAlignmentProfileRequest) ([]CpuAlignmentProfile, error) {
|
||||
res, err := e.GetCPUAlignmentProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var profiles []CpuAlignmentProfile
|
||||
|
||||
err = json.Unmarshal(res, &profiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
// GetCPUAlignmentProfileRaw gets CPU alignment profile of zone as an array of bytes
|
||||
func (e Zone) GetCPUAlignmentProfileRaw(ctx context.Context, req GetCPUAlignmentProfileRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/get_cpu_alignment_profile"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
45
pkg/cloudbroker/zone/list_cpu_alignment_profile.go
Normal file
45
pkg/cloudbroker/zone/list_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListCPUAlignmentProfileRequest struct to list CPU alignment profiles
|
||||
type ListCPUAlignmentProfileRequest struct {
|
||||
// ID of zone
|
||||
// Required: false
|
||||
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||||
}
|
||||
|
||||
// ListCPUAlignmentProfile gets list of CPU alignment profiles
|
||||
func (e Zone) ListCPUAlignmentProfile(ctx context.Context, req ListCPUAlignmentProfileRequest) (*ListCPUAlignmentProfiles, error) {
|
||||
res, err := e.ListCPUAlignmentProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListCPUAlignmentProfiles{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListCPUAlignmentProfileRaw gets list of CPU alignment profiles as an array of bytes
|
||||
func (e Zone) ListCPUAlignmentProfileRaw(ctx context.Context, req ListCPUAlignmentProfileRequest) ([]byte, error) {
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/list_cpu_alignment_profile"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -1,5 +1,65 @@
|
||||
package zone
|
||||
|
||||
// CPU alignment profile
|
||||
type CpuAlignmentProfile struct {
|
||||
// Profile name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Vendor
|
||||
Vendor string `json:"vendor"`
|
||||
|
||||
// Model
|
||||
Model string `json:"model"`
|
||||
}
|
||||
|
||||
// CPU alignment profile candidate
|
||||
type CpuAlignmentProfileCandidate struct {
|
||||
// Profile name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Vendor
|
||||
Vendor string `json:"vendor"`
|
||||
|
||||
// Model
|
||||
Model string `json:"model"`
|
||||
|
||||
// Count
|
||||
Count uint64 `json:"count"`
|
||||
|
||||
// Percentage
|
||||
Percentage uint64 `json:"percentage"`
|
||||
|
||||
// Required count
|
||||
RequiredCount uint64 `json:"required_count"`
|
||||
}
|
||||
|
||||
// Response for test_cpu_alignment_profile
|
||||
type TestCPUAlignmentProfileResult struct {
|
||||
// Profiles
|
||||
Profiles []CpuAlignmentProfile `json:"profiles"`
|
||||
|
||||
// Candidates
|
||||
Candidates []CpuAlignmentProfileCandidate `json:"candidates"`
|
||||
}
|
||||
|
||||
// Item for list_cpu_alignment_profile response
|
||||
type ItemCPUAlignmentProfile struct {
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
|
||||
// CPU alignment profiles
|
||||
CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"`
|
||||
}
|
||||
|
||||
// Response for list_cpu_alignment_profile
|
||||
type ListCPUAlignmentProfiles struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
|
||||
// Data
|
||||
Data []ItemCPUAlignmentProfile `json:"data"`
|
||||
}
|
||||
|
||||
type ListZones struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
@@ -96,6 +156,9 @@ type RecordZone struct {
|
||||
|
||||
// Domain
|
||||
Domain string `json:"domain"`
|
||||
|
||||
// CPU alignment profiles
|
||||
CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"`
|
||||
}
|
||||
|
||||
// A zone item from a list
|
||||
@@ -165,4 +228,7 @@ type ItemZone struct {
|
||||
|
||||
// Domain
|
||||
Domain string `json:"domain"`
|
||||
|
||||
// CPU alignment profiles
|
||||
CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"`
|
||||
}
|
||||
|
||||
51
pkg/cloudbroker/zone/test_cpu_alignment_profile.go
Normal file
51
pkg/cloudbroker/zone/test_cpu_alignment_profile.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// TestCPUAlignmentProfileRequest struct to test CPU alignment profile for zone
|
||||
type TestCPUAlignmentProfileRequest struct {
|
||||
// ID of zone
|
||||
// Required: true
|
||||
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||
|
||||
// Hypervisor similarity in percentage
|
||||
// Default: 70
|
||||
// Required: false
|
||||
HypervisorSimilarityInPercentage uint64 `url:"hypervisor_similarity_in_percentage,omitempty" json:"hypervisor_similarity_in_percentage,omitempty"`
|
||||
}
|
||||
|
||||
// TestCPUAlignmentProfile tests CPU alignment profile for zone
|
||||
func (e Zone) TestCPUAlignmentProfile(ctx context.Context, req TestCPUAlignmentProfileRequest) (*TestCPUAlignmentProfileResult, error) {
|
||||
res, err := e.TestCPUAlignmentProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := TestCPUAlignmentProfileResult{}
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// TestCPUAlignmentProfileRaw tests CPU alignment profile for zone and returns the result as an array of bytes
|
||||
func (e Zone) TestCPUAlignmentProfileRaw(ctx context.Context, req TestCPUAlignmentProfileRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/zone/test_cpu_alignment_profile"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user