This commit is contained in:
2023-03-14 14:45:51 +03:00
parent 42800ac4fe
commit f3a1a4c83f
202 changed files with 6199 additions and 155 deletions

View File

@@ -1,7 +1,7 @@
// API Actor for managing Compute Group. This actor is a final API for endusers to manage Compute Group
package bservice
import "github.com/rudecs/decort-sdk/interfaces"
import "repos.digitalenergy.online/BASIS/decort-golang-sdk/interfaces"
// Structure for creating request to bservice
type BService struct {

View File

@@ -0,0 +1,69 @@
package bservice
// FilterByID returns ListBasicServices with specified ID.
func (lbs ListBasicServices) FilterByID(id uint64) ListBasicServices {
predicate := func(ibs ItemBasicService) bool {
return ibs.ID == id
}
return lbs.FilterFunc(predicate)
}
// FilterByName returns ListBasicServices with specified Name.
func (lbs ListBasicServices) FilterByName(name string) ListBasicServices {
predicate := func(ibs ItemBasicService) bool {
return ibs.Name == name
}
return lbs.FilterFunc(predicate)
}
// FilterByRGID returns ListBasicServices with specified RGID.
func (lbs ListBasicServices) FilterByRGID(rgID uint64) ListBasicServices {
predicate := func(ibs ItemBasicService) bool {
return ibs.RGID == rgID
}
return lbs.FilterFunc(predicate)
}
// FilterByStatus returns ListBasicServices with specified Status.
func (lbs ListBasicServices) FilterByStatus(status string) ListBasicServices {
predicate := func(ibs ItemBasicService) bool {
return ibs.Status == status
}
return lbs.FilterFunc(predicate)
}
// FilterByTechStatus returns ListBasicServices with specified TechStatus.
func (lbs ListBasicServices) FilterByTechStatus(techStatus string) ListBasicServices {
predicate := func(ibs ItemBasicService) bool {
return ibs.TechStatus == techStatus
}
return lbs.FilterFunc(predicate)
}
// FilterFunc allows filtering ListResourceGroups based on a user-specified predicate.
func (lbs ListBasicServices) FilterFunc(predicate func(ItemBasicService) bool) ListBasicServices {
var result ListBasicServices
for _, item := range lbs {
if predicate(item) {
result = append(result, item)
}
}
return result
}
// FindOne returns first found ItemBasicService
// If none was found, returns an empty struct.
func (lbs ListBasicServices) FindOne() ItemBasicService {
if len(lbs) == 0 {
return ItemBasicService{}
}
return lbs[0]
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
"strconv"
"github.com/rudecs/decort-sdk/internal/validators"
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for resize the group

View File

@@ -0,0 +1,43 @@
package bservice
import (
"encoding/json"
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/serialization"
)
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
//
// In order to serialize with indent make sure to follow these guidelines:
// - First argument -> prefix
// - Second argument -> indent
func (lbs ListBasicServices) Serialize(params ...string) (serialization.Serialized, error) {
if len(lbs) == 0 {
return []byte{}, nil
}
if len(params) > 1 {
prefix := params[0]
indent := params[1]
return json.MarshalIndent(lbs, prefix, indent)
}
return json.Marshal(lbs)
}
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
//
// In order to serialize with indent make sure to follow these guidelines:
// - First argument -> prefix
// - Second argument -> indent
func (ibs ItemBasicService) Serialize(params ...string) (serialization.Serialized, error) {
if len(params) > 1 {
prefix := params[0]
indent := params[1]
return json.MarshalIndent(ibs, prefix, indent)
}
return json.Marshal(ibs)
}

View File

@@ -0,0 +1,60 @@
package bservice
import "sort"
// SortByCreatedTime sorts ListBasicServices by the CreatedTime field in ascending order.
//
// If inverse param is set to true, the order is reversed.
func (lbs ListBasicServices) SortByCreatedTime(inverse bool) ListBasicServices {
if len(lbs) < 2 {
return lbs
}
sort.Slice(lbs, func(i, j int) bool {
if inverse {
return lbs[i].CreatedTime > lbs[j].CreatedTime
}
return lbs[i].CreatedTime < lbs[j].CreatedTime
})
return lbs
}
// SortByUpdatedTime sorts ListBasicServices by the UpdatedTime field in ascending order.
//
// If inverse param is set to true, the order is reversed.
func (lbs ListBasicServices) SortByUpdatedTime(inverse bool) ListBasicServices {
if len(lbs) < 2 {
return lbs
}
sort.Slice(lbs, func(i, j int) bool {
if inverse {
return lbs[i].UpdatedTime > lbs[j].UpdatedTime
}
return lbs[i].UpdatedTime < lbs[j].UpdatedTime
})
return lbs
}
// SortByDeletedTime sorts ListBasicServices by the DeletedTime field in ascending order.
//
// If inverse param is set to true, the order is reversed.
func (lbs ListBasicServices) SortByDeletedTime(inverse bool) ListBasicServices {
if len(lbs) < 2 {
return lbs
}
sort.Slice(lbs, func(i, j int) bool {
if inverse {
return lbs[i].DeletedTime > lbs[j].DeletedTime
}
return lbs[i].DeletedTime < lbs[j].DeletedTime
})
return lbs
}