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

@@ -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

View 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]
}

View File

@@ -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

View 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)
}