2024-11-28 16:49:41 +01:00
package resources
2024-07-18 11:51:12 +02:00
import (
2024-11-28 11:05:54 +01:00
"cloud.o-forge.io/core/oc-lib/models/resources/resource_model"
2024-07-18 13:35:14 +02:00
"cloud.o-forge.io/core/oc-lib/models/utils"
2024-08-12 16:11:25 +02:00
"cloud.o-forge.io/core/oc-lib/tools"
2024-07-18 11:51:12 +02:00
)
2024-11-08 11:44:23 +01:00
2024-11-07 11:05:24 +01:00
// enum of public private or licenced data
2024-11-08 11:44:23 +01:00
type DataLicense int
2024-11-07 11:05:24 +01:00
const (
2024-11-08 11:44:23 +01:00
PUBLIC DataLicense = iota
PRIVATE
LICENCED
2024-11-07 11:05:24 +01:00
)
2024-11-08 11:44:23 +01:00
2024-11-07 11:05:24 +01:00
/ *
* Struct of Usage Conditions
2024-11-08 11:44:23 +01:00
* /
2024-11-07 11:05:24 +01:00
type UsageConditions struct {
2024-11-08 11:44:23 +01:00
Usage string ` json:"usage,omitempty" bson:"usage,omitempty" description:"usage of the data" ` // Usage is the usage of the data
2024-11-07 11:05:24 +01:00
Actors [ ] string ` json:"actors,omitempty" bson:"actors,omitempty" description:"actors of the data" ` // Actors is the actors of the data
}
2024-11-08 11:44:23 +01:00
2024-08-30 14:50:48 +02:00
/ *
* DataResource is a struct that represents a data resource
* it defines the resource data
* /
2024-07-19 10:54:58 +02:00
type DataResource struct {
2024-10-09 09:05:49 +02:00
resource_model . AbstractResource // AbstractResource contains the basic fields of an object (id, name)
resource_model . WebResource
2024-11-08 11:44:23 +01:00
Type string ` bson:"type,omitempty" json:"type,omitempty" ` // Type is the type of the storage
2024-11-07 11:05:24 +01:00
UsageConditions UsageConditions ` json:"usage_conditions,omitempty" bson:"usage_conditions,omitempty" description:"usage conditions of the data" ` // UsageConditions is the usage conditions of the data
2024-11-08 11:44:23 +01:00
License DataLicense ` json:"license" bson:"license" description:"license of the data" default:"0" ` // License is the license of the data
Interest DataLicense ` json:"interest" bson:"interest" description:"interest of the data" default:"0" ` // Interest is the interest of the data
Example string ` json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data" ` // Example is an example of the data
2024-07-18 11:51:12 +02:00
}
2024-11-28 11:05:54 +01:00
func ( d * DataResource ) GetAccessor ( peerID string , groups [ ] string , caller * tools . HTTPCaller ) utils . Accessor {
2024-11-28 16:49:41 +01:00
return New [ * DataResource ] ( tools . DATA_RESOURCE , peerID , groups , caller , func ( ) utils . DBObject { return & DataResource { } } ) // Create a new instance of the accessor
2024-07-18 11:51:12 +02:00
}