v1.2.1
This commit is contained in:
@@ -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 edit config fields
|
||||
|
||||
69
pkg/cloudbroker/sep/filter.go
Normal file
69
pkg/cloudbroker/sep/filter.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package sep
|
||||
|
||||
// FilterByID returns ListSEP with specified ID.
|
||||
func (lsep ListSEP) FilterByID(id uint64) ListSEP {
|
||||
predicate := func(rsep RecordSEP) bool {
|
||||
return rsep.ID == id
|
||||
}
|
||||
|
||||
return lsep.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListSEP with specified Name.
|
||||
func (lsep ListSEP) FilterByName(name string) ListSEP {
|
||||
predicate := func(rsep RecordSEP) bool {
|
||||
return rsep.Name == name
|
||||
}
|
||||
|
||||
return lsep.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByObjStatus returns ListSEP with specified ObjStatus.
|
||||
func (lsep ListSEP) FilterByObjStatus(objStatus string) ListSEP {
|
||||
predicate := func(rsep RecordSEP) bool {
|
||||
return rsep.ObjStatus == objStatus
|
||||
}
|
||||
|
||||
return lsep.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByTechStatus returns ListSEP with specified TechStatus.
|
||||
func (lsep ListSEP) FilterByTechStatus(techStatus string) ListSEP {
|
||||
predicate := func(rsep RecordSEP) bool {
|
||||
return rsep.TechStatus == techStatus
|
||||
}
|
||||
|
||||
return lsep.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByType returns ListSEP with specified Type.
|
||||
func (lsep ListSEP) FilterByType(sepType string) ListSEP {
|
||||
predicate := func(rsep RecordSEP) bool {
|
||||
return rsep.Type == sepType
|
||||
}
|
||||
|
||||
return lsep.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListSEP based on user-specified predicate.
|
||||
func (lsep ListSEP) FilterFunc(predicate func(RecordSEP) bool) ListSEP {
|
||||
var result ListSEP
|
||||
|
||||
for _, item := range lsep {
|
||||
if predicate(item) {
|
||||
result = append(result, item)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found RecordSEP
|
||||
// If none was found, returns an empty struct.
|
||||
func (lsep ListSEP) FindOne() RecordSEP {
|
||||
if len(lsep) == 0 {
|
||||
return RecordSEP{}
|
||||
}
|
||||
|
||||
return lsep[0]
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"github.com/rudecs/decort-sdk/interfaces"
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to storage endpoint provider
|
||||
|
||||
43
pkg/cloudbroker/sep/serialize.go
Normal file
43
pkg/cloudbroker/sep/serialize.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package sep
|
||||
|
||||
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 (lsep ListSEP) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(lsep) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(lsep, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(lsep)
|
||||
}
|
||||
|
||||
// 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 (rsep RecordSEP) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(rsep, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(rsep)
|
||||
}
|
||||
Reference in New Issue
Block a user