add a web resource concept for data + storage
This commit is contained in:
parent
ba6ac86bff
commit
b90ffbc4f0
@ -8,6 +8,12 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type WebResource struct {
|
||||||
|
Type string `bson:"type,omitempty" json:"type,omitempty"` // Type is the type of the storage
|
||||||
|
Protocol string `bson:"protocol,omitempty" json:"protocol,omitempty"` // Protocol is the protocol of the URL
|
||||||
|
Path string `bson:"path,omitempty" json:"path,omitempty"` // Path is the path of the URL
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AbstractResource is a struct that represents a resource
|
* AbstractResource is a struct that represents a resource
|
||||||
* it defines the resource data
|
* it defines the resource data
|
||||||
|
@ -13,10 +13,9 @@ import (
|
|||||||
* it defines the resource data
|
* it defines the resource data
|
||||||
*/
|
*/
|
||||||
type DataResource struct {
|
type DataResource struct {
|
||||||
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
||||||
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
|
resource_model.WebResource
|
||||||
DataType string `json:"datatype,omitempty" bson:"datatype,omitempty"` // DataType is the type of the data
|
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"` // Example is an example of the data
|
||||||
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"` // Example is an example of the data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dma *DataResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
func (dma *DataResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
||||||
|
@ -10,7 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreOneData(t *testing.T) {
|
func TestStoreOneData(t *testing.T) {
|
||||||
d := DataResource{DataType: "jpeg", Example: "123456",
|
d := DataResource{
|
||||||
|
WebResource: resource_model.WebResource{
|
||||||
|
Type: "jpeg", Protocol: "http", Path: "azerty.fr",
|
||||||
|
},
|
||||||
|
Example: "123456",
|
||||||
AbstractResource: resource_model.AbstractResource{
|
AbstractResource: resource_model.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
@ -28,7 +32,11 @@ func TestStoreOneData(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadOneDate(t *testing.T) {
|
func TestLoadOneDate(t *testing.T) {
|
||||||
d := DataResource{DataType: "jpeg", Example: "123456",
|
d := DataResource{
|
||||||
|
WebResource: resource_model.WebResource{
|
||||||
|
Type: "jpeg", Protocol: "http", Path: "azerty.fr",
|
||||||
|
},
|
||||||
|
Example: "123456",
|
||||||
AbstractResource: resource_model.AbstractResource{
|
AbstractResource: resource_model.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
|
@ -28,26 +28,20 @@ func (dma StorageType) ToArgo() string {
|
|||||||
return argoType[dma]
|
return argoType[dma]
|
||||||
}
|
}
|
||||||
|
|
||||||
type URL struct {
|
|
||||||
Protocol string `bson:"protocol,omitempty" json:"protocol,omitempty"` // Protocol is the protocol of the URL
|
|
||||||
Path string `bson:"path,omitempty" json:"path,omitempty"` // Path is the path of the URL
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* StorageResource is a struct that represents a storage resource
|
* StorageResource is a struct that represents a storage resource
|
||||||
* it defines the resource storage
|
* it defines the resource storage
|
||||||
*/
|
*/
|
||||||
type StorageResource struct {
|
type StorageResource struct {
|
||||||
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
||||||
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage
|
resource_model.WebResource
|
||||||
Type string `bson:"type,omitempty" json:"type,omitempty"` // Type is the type of the storage
|
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage
|
||||||
SizeType StorageType `bson:"size_type" json:"size_type" default:"0"` // SizeType is the type of the storage size
|
SizeType StorageType `bson:"size_type" json:"size_type" default:"0"` // SizeType is the type of the storage size
|
||||||
Size uint `bson:"size,omitempty" json:"size,omitempty"` // Size is the size of the storage
|
Size uint `bson:"size,omitempty" json:"size,omitempty"` // Size is the size of the storage
|
||||||
Url *URL `bson:"url,omitempty" json:"url,omitempty"` // Will allow to select between several protocols
|
Local bool `bson:"local" json:"local"` // Local is a flag that indicates if the storage is local
|
||||||
Local bool `bson:"local" json:"local"` // Local is a flag that indicates if the storage is local
|
Encryption bool `bson:"encryption,omitempty" json:"encryption,omitempty"` // Encryption is a flag that indicates if the storage is encrypted
|
||||||
Encryption bool `bson:"encryption,omitempty" json:"encryption,omitempty"` // Encryption is a flag that indicates if the storage is encrypted
|
Redundancy string `bson:"redundancy,omitempty" json:"redundancy,omitempty"` // Redundancy is the redundancy of the storage
|
||||||
Redundancy string `bson:"redundancy,omitempty" json:"redundancy,omitempty"` // Redundancy is the redundancy of the storage
|
Throughput string `bson:"throughput,omitempty" json:"throughput,omitempty"` // Throughput is the throughput of the storage
|
||||||
Throughput string `bson:"throughput,omitempty" json:"throughput,omitempty"` // Throughput is the throughput of the storage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dma *StorageResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
func (dma *StorageResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreOneStorage(t *testing.T) {
|
func TestStoreOneStorage(t *testing.T) {
|
||||||
s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
|
s := StorageResource{Size: 123, WebResource: resource_model.WebResource{Protocol: "http", Path: "azerty.fr"},
|
||||||
AbstractResource: resource_model.AbstractResource{
|
AbstractResource: resource_model.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
@ -28,7 +28,7 @@ func TestStoreOneStorage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadOneStorage(t *testing.T) {
|
func TestLoadOneStorage(t *testing.T) {
|
||||||
s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
|
s := StorageResource{Size: 123, WebResource: resource_model.WebResource{Protocol: "http", Path: "azerty.fr"},
|
||||||
AbstractResource: resource_model.AbstractResource{
|
AbstractResource: resource_model.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
|
Loading…
Reference in New Issue
Block a user