diff --git a/.spelling b/.spelling index a82b9ac38..852ab60d0 100644 --- a/.spelling +++ b/.spelling @@ -25,6 +25,8 @@ Aporeto aporeto-crds aporeto-operator AppCredential +ARN +arn attachedInterfaces auditd AuditProfile @@ -46,6 +48,8 @@ AutomationTemplate availabilityZone AvailabilityZone AWSAccount +AWSAsset +AWSAssets azure Azure backend @@ -398,6 +402,8 @@ resourceType resourceID ResponseTypesSupported Rexray +RRN +rrn rql ruleset runtime @@ -475,6 +481,7 @@ vCPUs vince VMs VPC +vpc VPCs v1 Webhook diff --git a/awsasset.go b/awsasset.go new file mode 100644 index 000000000..91e75dc81 --- /dev/null +++ b/awsasset.go @@ -0,0 +1,1515 @@ +// Code generated by elegen. DO NOT EDIT. +// Source: go.aporeto.io/elemental (templates/model.gotpl) + +package gaia + +import ( + "fmt" + "time" + + "github.com/globalsign/mgo/bson" + "github.com/mitchellh/copystructure" + "go.aporeto.io/elemental" +) + +// AWSAssetKindValue represents the possible values for attribute "kind". +type AWSAssetKindValue string + +const ( + // AWSAssetKindInstance represents the value Instance. + AWSAssetKindInstance AWSAssetKindValue = "Instance" + + // AWSAssetKindInternetGateway represents the value InternetGateway. + AWSAssetKindInternetGateway AWSAssetKindValue = "InternetGateway" + + // AWSAssetKindNetworkACL represents the value NetworkACL. + AWSAssetKindNetworkACL AWSAssetKindValue = "NetworkACL" + + // AWSAssetKindNetworkInterface represents the value NetworkInterface. + AWSAssetKindNetworkInterface AWSAssetKindValue = "NetworkInterface" + + // AWSAssetKindPending represents the value Pending. + AWSAssetKindPending AWSAssetKindValue = "Pending" + + // AWSAssetKindSecurityGroup represents the value SecurityGroup. + AWSAssetKindSecurityGroup AWSAssetKindValue = "SecurityGroup" + + // AWSAssetKindSubnet represents the value Subnet. + AWSAssetKindSubnet AWSAssetKindValue = "Subnet" + + // AWSAssetKindVPC represents the value VPC. + AWSAssetKindVPC AWSAssetKindValue = "VPC" +) + +// AWSAssetIdentity represents the Identity of the object. +var AWSAssetIdentity = elemental.Identity{ + Name: "awsasset", + Category: "awsassets", + Package: "pandemona", + Private: false, +} + +// AWSAssetsList represents a list of AWSAssets +type AWSAssetsList []*AWSAsset + +// Identity returns the identity of the objects in the list. +func (o AWSAssetsList) Identity() elemental.Identity { + + return AWSAssetIdentity +} + +// Copy returns a pointer to a copy the AWSAssetsList. +func (o AWSAssetsList) Copy() elemental.Identifiables { + + out := append(AWSAssetsList{}, o...) + return &out +} + +// Append appends the objects to the a new copy of the AWSAssetsList. +func (o AWSAssetsList) Append(objects ...elemental.Identifiable) elemental.Identifiables { + + out := append(AWSAssetsList{}, o...) + for _, obj := range objects { + out = append(out, obj.(*AWSAsset)) + } + + return out +} + +// List converts the object to an elemental.IdentifiablesList. +func (o AWSAssetsList) List() elemental.IdentifiablesList { + + out := make(elemental.IdentifiablesList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i] + } + + return out +} + +// DefaultOrder returns the default ordering fields of the content. +func (o AWSAssetsList) DefaultOrder() []string { + + return []string{} +} + +// ToSparse returns the AWSAssetsList converted to SparseAWSAssetsList. +// Objects in the list will only contain the given fields. No field means entire field set. +func (o AWSAssetsList) ToSparse(fields ...string) elemental.Identifiables { + + out := make(SparseAWSAssetsList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i].ToSparse(fields...).(*SparseAWSAsset) + } + + return out +} + +// Version returns the version of the content. +func (o AWSAssetsList) Version() int { + + return 1 +} + +// AWSAsset represents the model of a awsasset +type AWSAsset struct { + // Identifier of the object. + ID string `json:"ID" msgpack:"ID" bson:"-" mapstructure:"ID,omitempty"` + + // The 12 digit ID of the AWS account the resource belongs. + AccountID string `json:"accountID,omitempty" msgpack:"accountID,omitempty" bson:"accountid,omitempty" mapstructure:"accountID,omitempty"` + + // The ARN of the resource in AWS. + Arn string `json:"arn" msgpack:"arn" bson:"arn" mapstructure:"arn,omitempty"` + + // Creation date of the object. + CreateTime time.Time `json:"createTime" msgpack:"createTime" bson:"createtime" mapstructure:"createTime,omitempty"` + + // The JSON-encoded data that represents the resource. + Data []byte `json:"data" msgpack:"data" bson:"data" mapstructure:"data,omitempty"` + + // Contextual values that can be used to narrow searching of resources if the + // arn or resourceID are not known. For instance, it could be used to store + // a resource's Subnet or VPC ID. + DenormedFields []string `json:"denormedFields" msgpack:"denormedFields" bson:"denormedfields" mapstructure:"denormedFields,omitempty"` + + // The specific kind of the resource. + Kind AWSAssetKindValue `json:"kind" msgpack:"kind" bson:"kind" mapstructure:"kind,omitempty"` + + // Internal property maintaining migrations information. + MigrationsLog map[string]string `json:"-" msgpack:"-" bson:"migrationslog,omitempty" mapstructure:"-,omitempty"` + + // The name of the resource. + Name string `json:"name" msgpack:"name" bson:"name" mapstructure:"name,omitempty"` + + // Namespace tag attached to an entity. + Namespace string `json:"namespace" msgpack:"namespace" bson:"namespace" mapstructure:"namespace,omitempty"` + + // The resource identifier in PrismaCloud. + PrismaRRN string `json:"prismaRRN,omitempty" msgpack:"prismaRRN,omitempty" bson:"prismarrn,omitempty" mapstructure:"prismaRRN,omitempty"` + + // The region this resource exists in according to PrismaCloud. Note that the + // resource may exists in a different region as described by AWS. + PrismaRegion string `json:"prismaRegion" msgpack:"prismaRegion" bson:"prismaregion" mapstructure:"prismaRegion,omitempty"` + + // A resource ID that will mainly be used in RQL queries. + ResourceID string `json:"resourceID" msgpack:"resourceID" bson:"resourceid" mapstructure:"resourceID,omitempty"` + + // Last update date of the object. + UpdateTime time.Time `json:"updateTime" msgpack:"updateTime" bson:"updatetime" mapstructure:"updateTime,omitempty"` + + // geographical hash of the data. This is used for sharding and + // georedundancy. + ZHash int `json:"-" msgpack:"-" bson:"zhash" mapstructure:"-,omitempty"` + + // Logical storage zone. Used for sharding. + Zone int `json:"-" msgpack:"-" bson:"zone" mapstructure:"-,omitempty"` + + ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"` +} + +// NewAWSAsset returns a new *AWSAsset +func NewAWSAsset() *AWSAsset { + + return &AWSAsset{ + ModelVersion: 1, + Data: []byte{}, + DenormedFields: []string{}, + Kind: AWSAssetKindPending, + MigrationsLog: map[string]string{}, + } +} + +// Identity returns the Identity of the object. +func (o *AWSAsset) Identity() elemental.Identity { + + return AWSAssetIdentity +} + +// Identifier returns the value of the object's unique identifier. +func (o *AWSAsset) Identifier() string { + + return o.ID +} + +// SetIdentifier sets the value of the object's unique identifier. +func (o *AWSAsset) SetIdentifier(id string) { + + o.ID = id +} + +// GetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *AWSAsset) GetBSON() (any, error) { + + if o == nil { + return nil, nil + } + + s := &mongoAttributesAWSAsset{} + + if o.ID != "" { + s.ID = bson.ObjectIdHex(o.ID) + } + s.AccountID = o.AccountID + s.Arn = o.Arn + s.CreateTime = o.CreateTime + s.Data = o.Data + s.DenormedFields = o.DenormedFields + s.Kind = o.Kind + s.MigrationsLog = o.MigrationsLog + s.Name = o.Name + s.Namespace = o.Namespace + s.PrismaRRN = o.PrismaRRN + s.PrismaRegion = o.PrismaRegion + s.ResourceID = o.ResourceID + s.UpdateTime = o.UpdateTime + s.ZHash = o.ZHash + s.Zone = o.Zone + + return s, nil +} + +// SetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *AWSAsset) SetBSON(raw bson.Raw) error { + + if o == nil { + return nil + } + + s := &mongoAttributesAWSAsset{} + if err := raw.Unmarshal(s); err != nil { + return err + } + + o.ID = s.ID.Hex() + o.AccountID = s.AccountID + o.Arn = s.Arn + o.CreateTime = s.CreateTime + o.Data = s.Data + o.DenormedFields = s.DenormedFields + o.Kind = s.Kind + o.MigrationsLog = s.MigrationsLog + o.Name = s.Name + o.Namespace = s.Namespace + o.PrismaRRN = s.PrismaRRN + o.PrismaRegion = s.PrismaRegion + o.ResourceID = s.ResourceID + o.UpdateTime = s.UpdateTime + o.ZHash = s.ZHash + o.Zone = s.Zone + + return nil +} + +// Version returns the hardcoded version of the model. +func (o *AWSAsset) Version() int { + + return 1 +} + +// BleveType implements the bleve.Classifier Interface. +func (o *AWSAsset) BleveType() string { + + return "awsasset" +} + +// DefaultOrder returns the list of default ordering fields. +func (o *AWSAsset) DefaultOrder() []string { + + return []string{} +} + +// Doc returns the documentation for the object +func (o *AWSAsset) Doc() string { + + return `Represents a read-only AWS cloud resource such as a virtual machine.` +} + +func (o *AWSAsset) String() string { + + return fmt.Sprintf("<%s:%s>", o.Identity().Name, o.Identifier()) +} + +// GetCreateTime returns the CreateTime of the receiver. +func (o *AWSAsset) GetCreateTime() time.Time { + + return o.CreateTime +} + +// SetCreateTime sets the property CreateTime of the receiver using the given value. +func (o *AWSAsset) SetCreateTime(createTime time.Time) { + + o.CreateTime = createTime +} + +// GetMigrationsLog returns the MigrationsLog of the receiver. +func (o *AWSAsset) GetMigrationsLog() map[string]string { + + return o.MigrationsLog +} + +// SetMigrationsLog sets the property MigrationsLog of the receiver using the given value. +func (o *AWSAsset) SetMigrationsLog(migrationsLog map[string]string) { + + o.MigrationsLog = migrationsLog +} + +// GetNamespace returns the Namespace of the receiver. +func (o *AWSAsset) GetNamespace() string { + + return o.Namespace +} + +// SetNamespace sets the property Namespace of the receiver using the given value. +func (o *AWSAsset) SetNamespace(namespace string) { + + o.Namespace = namespace +} + +// GetUpdateTime returns the UpdateTime of the receiver. +func (o *AWSAsset) GetUpdateTime() time.Time { + + return o.UpdateTime +} + +// SetUpdateTime sets the property UpdateTime of the receiver using the given value. +func (o *AWSAsset) SetUpdateTime(updateTime time.Time) { + + o.UpdateTime = updateTime +} + +// GetZHash returns the ZHash of the receiver. +func (o *AWSAsset) GetZHash() int { + + return o.ZHash +} + +// SetZHash sets the property ZHash of the receiver using the given value. +func (o *AWSAsset) SetZHash(zHash int) { + + o.ZHash = zHash +} + +// GetZone returns the Zone of the receiver. +func (o *AWSAsset) GetZone() int { + + return o.Zone +} + +// SetZone sets the property Zone of the receiver using the given value. +func (o *AWSAsset) SetZone(zone int) { + + o.Zone = zone +} + +// ToSparse returns the sparse version of the model. +// The returned object will only contain the given fields. No field means entire field set. +func (o *AWSAsset) ToSparse(fields ...string) elemental.SparseIdentifiable { + + if len(fields) == 0 { + // nolint: goimports + return &SparseAWSAsset{ + ID: &o.ID, + AccountID: &o.AccountID, + Arn: &o.Arn, + CreateTime: &o.CreateTime, + Data: &o.Data, + DenormedFields: &o.DenormedFields, + Kind: &o.Kind, + MigrationsLog: &o.MigrationsLog, + Name: &o.Name, + Namespace: &o.Namespace, + PrismaRRN: &o.PrismaRRN, + PrismaRegion: &o.PrismaRegion, + ResourceID: &o.ResourceID, + UpdateTime: &o.UpdateTime, + ZHash: &o.ZHash, + Zone: &o.Zone, + } + } + + sp := &SparseAWSAsset{} + for _, f := range fields { + switch f { + case "ID": + sp.ID = &(o.ID) + case "accountID": + sp.AccountID = &(o.AccountID) + case "arn": + sp.Arn = &(o.Arn) + case "createTime": + sp.CreateTime = &(o.CreateTime) + case "data": + sp.Data = &(o.Data) + case "denormedFields": + sp.DenormedFields = &(o.DenormedFields) + case "kind": + sp.Kind = &(o.Kind) + case "migrationsLog": + sp.MigrationsLog = &(o.MigrationsLog) + case "name": + sp.Name = &(o.Name) + case "namespace": + sp.Namespace = &(o.Namespace) + case "prismaRRN": + sp.PrismaRRN = &(o.PrismaRRN) + case "prismaRegion": + sp.PrismaRegion = &(o.PrismaRegion) + case "resourceID": + sp.ResourceID = &(o.ResourceID) + case "updateTime": + sp.UpdateTime = &(o.UpdateTime) + case "zHash": + sp.ZHash = &(o.ZHash) + case "zone": + sp.Zone = &(o.Zone) + } + } + + return sp +} + +// Patch apply the non nil value of a *SparseAWSAsset to the object. +func (o *AWSAsset) Patch(sparse elemental.SparseIdentifiable) { + if !sparse.Identity().IsEqual(o.Identity()) { + panic("cannot patch from a parse with different identity") + } + + so := sparse.(*SparseAWSAsset) + if so.ID != nil { + o.ID = *so.ID + } + if so.AccountID != nil { + o.AccountID = *so.AccountID + } + if so.Arn != nil { + o.Arn = *so.Arn + } + if so.CreateTime != nil { + o.CreateTime = *so.CreateTime + } + if so.Data != nil { + o.Data = *so.Data + } + if so.DenormedFields != nil { + o.DenormedFields = *so.DenormedFields + } + if so.Kind != nil { + o.Kind = *so.Kind + } + if so.MigrationsLog != nil { + o.MigrationsLog = *so.MigrationsLog + } + if so.Name != nil { + o.Name = *so.Name + } + if so.Namespace != nil { + o.Namespace = *so.Namespace + } + if so.PrismaRRN != nil { + o.PrismaRRN = *so.PrismaRRN + } + if so.PrismaRegion != nil { + o.PrismaRegion = *so.PrismaRegion + } + if so.ResourceID != nil { + o.ResourceID = *so.ResourceID + } + if so.UpdateTime != nil { + o.UpdateTime = *so.UpdateTime + } + if so.ZHash != nil { + o.ZHash = *so.ZHash + } + if so.Zone != nil { + o.Zone = *so.Zone + } +} + +// DeepCopy returns a deep copy if the AWSAsset. +func (o *AWSAsset) DeepCopy() *AWSAsset { + + if o == nil { + return nil + } + + out := &AWSAsset{} + o.DeepCopyInto(out) + + return out +} + +// DeepCopyInto copies the receiver into the given *AWSAsset. +func (o *AWSAsset) DeepCopyInto(out *AWSAsset) { + + target, err := copystructure.Copy(o) + if err != nil { + panic(fmt.Sprintf("Unable to deepcopy AWSAsset: %s", err)) + } + + *out = *target.(*AWSAsset) +} + +// Validate valides the current information stored into the structure. +func (o *AWSAsset) Validate() error { + + errors := elemental.Errors{} + requiredErrors := elemental.Errors{} + + if err := elemental.ValidateRequiredExternal("data", o.Data); err != nil { + requiredErrors = requiredErrors.Append(err) + } + + if err := elemental.ValidateStringInList("kind", string(o.Kind), []string{"Pending", "Instance", "NetworkInterface", "VPC", "Subnet", "NetworkACL", "InternetGateway", "SecurityGroup"}, true); err != nil { + errors = errors.Append(err) + } + + if len(requiredErrors) > 0 { + return requiredErrors + } + + if len(errors) > 0 { + return errors + } + + return nil +} + +// SpecificationForAttribute returns the AttributeSpecification for the given attribute name key. +func (*AWSAsset) SpecificationForAttribute(name string) elemental.AttributeSpecification { + + if v, ok := AWSAssetAttributesMap[name]; ok { + return v + } + + // We could not find it, so let's check on the lower case indexed spec map + return AWSAssetLowerCaseAttributesMap[name] +} + +// AttributeSpecifications returns the full attribute specifications map. +func (*AWSAsset) AttributeSpecifications() map[string]elemental.AttributeSpecification { + + return AWSAssetAttributesMap +} + +// ValueForAttribute returns the value for the given attribute. +// This is a very advanced function that you should not need but in some +// very specific use cases. +func (o *AWSAsset) ValueForAttribute(name string) any { + + switch name { + case "ID": + return o.ID + case "accountID": + return o.AccountID + case "arn": + return o.Arn + case "createTime": + return o.CreateTime + case "data": + return o.Data + case "denormedFields": + return o.DenormedFields + case "kind": + return o.Kind + case "migrationsLog": + return o.MigrationsLog + case "name": + return o.Name + case "namespace": + return o.Namespace + case "prismaRRN": + return o.PrismaRRN + case "prismaRegion": + return o.PrismaRegion + case "resourceID": + return o.ResourceID + case "updateTime": + return o.UpdateTime + case "zHash": + return o.ZHash + case "zone": + return o.Zone + } + + return nil +} + +// AWSAssetAttributesMap represents the map of attribute for AWSAsset. +var AWSAssetAttributesMap = map[string]elemental.AttributeSpecification{ + "ID": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "_id", + ConvertedName: "ID", + Description: `Identifier of the object.`, + Exposed: true, + Filterable: true, + Identifier: true, + Name: "ID", + Orderable: true, + ReadOnly: true, + Stored: true, + Type: "string", + }, + "AccountID": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "accountid", + ConvertedName: "AccountID", + Description: `The 12 digit ID of the AWS account the resource belongs.`, + Exposed: true, + Name: "accountID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "Arn": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "arn", + ConvertedName: "Arn", + Description: `The ARN of the resource in AWS.`, + Exposed: true, + Name: "arn", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "CreateTime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "createtime", + ConvertedName: "CreateTime", + Description: `Creation date of the object.`, + Exposed: true, + Getter: true, + Name: "createTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "Data": { + AllowedChoices: []string{}, + BSONFieldName: "data", + ConvertedName: "Data", + Description: `The JSON-encoded data that represents the resource.`, + Exposed: true, + Name: "data", + Required: true, + Stored: true, + SubType: "[]byte", + Type: "external", + }, + "DenormedFields": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "denormedfields", + ConvertedName: "DenormedFields", + Description: `Contextual values that can be used to narrow searching of resources if the +arn or resourceID are not known. For instance, it could be used to store +a resource's Subnet or VPC ID.`, + Exposed: true, + Name: "denormedFields", + ReadOnly: true, + Stored: true, + SubType: "string", + Type: "list", + }, + "Kind": { + AllowedChoices: []string{"Pending", "Instance", "NetworkInterface", "VPC", "Subnet", "NetworkACL", "InternetGateway", "SecurityGroup"}, + Autogenerated: true, + BSONFieldName: "kind", + ConvertedName: "Kind", + DefaultValue: AWSAssetKindPending, + Description: `The specific kind of the resource.`, + Exposed: true, + Name: "kind", + ReadOnly: true, + Stored: true, + Type: "enum", + }, + "MigrationsLog": { + AllowedChoices: []string{}, + BSONFieldName: "migrationslog", + ConvertedName: "MigrationsLog", + Description: `Internal property maintaining migrations information.`, + Getter: true, + Name: "migrationsLog", + Setter: true, + Stored: true, + SubType: "map[string]string", + Type: "external", + }, + "Name": { + AllowedChoices: []string{}, + BSONFieldName: "name", + ConvertedName: "Name", + Description: `The name of the resource.`, + Exposed: true, + Name: "name", + Stored: true, + Type: "string", + }, + "Namespace": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "namespace", + ConvertedName: "Namespace", + Description: `Namespace tag attached to an entity.`, + Exposed: true, + Filterable: true, + Getter: true, + Name: "namespace", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "string", + }, + "PrismaRRN": { + AllowedChoices: []string{}, + BSONFieldName: "prismarrn", + ConvertedName: "PrismaRRN", + Description: `The resource identifier in PrismaCloud.`, + Exposed: true, + Name: "prismaRRN", + Stored: true, + Type: "string", + }, + "PrismaRegion": { + AllowedChoices: []string{}, + BSONFieldName: "prismaregion", + ConvertedName: "PrismaRegion", + Description: `The region this resource exists in according to PrismaCloud. Note that the +resource may exists in a different region as described by AWS.`, + Exposed: true, + Name: "prismaRegion", + Stored: true, + Type: "string", + }, + "ResourceID": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "resourceid", + ConvertedName: "ResourceID", + Description: `A resource ID that will mainly be used in RQL queries.`, + Exposed: true, + Name: "resourceID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "UpdateTime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "updatetime", + ConvertedName: "UpdateTime", + Description: `Last update date of the object.`, + Exposed: true, + Getter: true, + Name: "updateTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "ZHash": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zhash", + ConvertedName: "ZHash", + Description: `geographical hash of the data. This is used for sharding and +georedundancy.`, + Getter: true, + Name: "zHash", + ReadOnly: true, + Setter: true, + Stored: true, + Type: "integer", + }, + "Zone": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zone", + ConvertedName: "Zone", + Description: `Logical storage zone. Used for sharding.`, + Getter: true, + Name: "zone", + ReadOnly: true, + Setter: true, + Stored: true, + Transient: true, + Type: "integer", + }, +} + +// AWSAssetLowerCaseAttributesMap represents the map of attribute for AWSAsset. +var AWSAssetLowerCaseAttributesMap = map[string]elemental.AttributeSpecification{ + "id": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "_id", + ConvertedName: "ID", + Description: `Identifier of the object.`, + Exposed: true, + Filterable: true, + Identifier: true, + Name: "ID", + Orderable: true, + ReadOnly: true, + Stored: true, + Type: "string", + }, + "accountid": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "accountid", + ConvertedName: "AccountID", + Description: `The 12 digit ID of the AWS account the resource belongs.`, + Exposed: true, + Name: "accountID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "arn": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "arn", + ConvertedName: "Arn", + Description: `The ARN of the resource in AWS.`, + Exposed: true, + Name: "arn", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "createtime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "createtime", + ConvertedName: "CreateTime", + Description: `Creation date of the object.`, + Exposed: true, + Getter: true, + Name: "createTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "data": { + AllowedChoices: []string{}, + BSONFieldName: "data", + ConvertedName: "Data", + Description: `The JSON-encoded data that represents the resource.`, + Exposed: true, + Name: "data", + Required: true, + Stored: true, + SubType: "[]byte", + Type: "external", + }, + "denormedfields": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "denormedfields", + ConvertedName: "DenormedFields", + Description: `Contextual values that can be used to narrow searching of resources if the +arn or resourceID are not known. For instance, it could be used to store +a resource's Subnet or VPC ID.`, + Exposed: true, + Name: "denormedFields", + ReadOnly: true, + Stored: true, + SubType: "string", + Type: "list", + }, + "kind": { + AllowedChoices: []string{"Pending", "Instance", "NetworkInterface", "VPC", "Subnet", "NetworkACL", "InternetGateway", "SecurityGroup"}, + Autogenerated: true, + BSONFieldName: "kind", + ConvertedName: "Kind", + DefaultValue: AWSAssetKindPending, + Description: `The specific kind of the resource.`, + Exposed: true, + Name: "kind", + ReadOnly: true, + Stored: true, + Type: "enum", + }, + "migrationslog": { + AllowedChoices: []string{}, + BSONFieldName: "migrationslog", + ConvertedName: "MigrationsLog", + Description: `Internal property maintaining migrations information.`, + Getter: true, + Name: "migrationsLog", + Setter: true, + Stored: true, + SubType: "map[string]string", + Type: "external", + }, + "name": { + AllowedChoices: []string{}, + BSONFieldName: "name", + ConvertedName: "Name", + Description: `The name of the resource.`, + Exposed: true, + Name: "name", + Stored: true, + Type: "string", + }, + "namespace": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "namespace", + ConvertedName: "Namespace", + Description: `Namespace tag attached to an entity.`, + Exposed: true, + Filterable: true, + Getter: true, + Name: "namespace", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "string", + }, + "prismarrn": { + AllowedChoices: []string{}, + BSONFieldName: "prismarrn", + ConvertedName: "PrismaRRN", + Description: `The resource identifier in PrismaCloud.`, + Exposed: true, + Name: "prismaRRN", + Stored: true, + Type: "string", + }, + "prismaregion": { + AllowedChoices: []string{}, + BSONFieldName: "prismaregion", + ConvertedName: "PrismaRegion", + Description: `The region this resource exists in according to PrismaCloud. Note that the +resource may exists in a different region as described by AWS.`, + Exposed: true, + Name: "prismaRegion", + Stored: true, + Type: "string", + }, + "resourceid": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "resourceid", + ConvertedName: "ResourceID", + Description: `A resource ID that will mainly be used in RQL queries.`, + Exposed: true, + Name: "resourceID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "updatetime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "updatetime", + ConvertedName: "UpdateTime", + Description: `Last update date of the object.`, + Exposed: true, + Getter: true, + Name: "updateTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "zhash": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zhash", + ConvertedName: "ZHash", + Description: `geographical hash of the data. This is used for sharding and +georedundancy.`, + Getter: true, + Name: "zHash", + ReadOnly: true, + Setter: true, + Stored: true, + Type: "integer", + }, + "zone": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zone", + ConvertedName: "Zone", + Description: `Logical storage zone. Used for sharding.`, + Getter: true, + Name: "zone", + ReadOnly: true, + Setter: true, + Stored: true, + Transient: true, + Type: "integer", + }, +} + +// SparseAWSAssetsList represents a list of SparseAWSAssets +type SparseAWSAssetsList []*SparseAWSAsset + +// Identity returns the identity of the objects in the list. +func (o SparseAWSAssetsList) Identity() elemental.Identity { + + return AWSAssetIdentity +} + +// Copy returns a pointer to a copy the SparseAWSAssetsList. +func (o SparseAWSAssetsList) Copy() elemental.Identifiables { + + copy := append(SparseAWSAssetsList{}, o...) + return © +} + +// Append appends the objects to the a new copy of the SparseAWSAssetsList. +func (o SparseAWSAssetsList) Append(objects ...elemental.Identifiable) elemental.Identifiables { + + out := append(SparseAWSAssetsList{}, o...) + for _, obj := range objects { + out = append(out, obj.(*SparseAWSAsset)) + } + + return out +} + +// List converts the object to an elemental.IdentifiablesList. +func (o SparseAWSAssetsList) List() elemental.IdentifiablesList { + + out := make(elemental.IdentifiablesList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i] + } + + return out +} + +// DefaultOrder returns the default ordering fields of the content. +func (o SparseAWSAssetsList) DefaultOrder() []string { + + return []string{} +} + +// ToPlain returns the SparseAWSAssetsList converted to AWSAssetsList. +func (o SparseAWSAssetsList) ToPlain() elemental.IdentifiablesList { + + out := make(elemental.IdentifiablesList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i].ToPlain() + } + + return out +} + +// Version returns the version of the content. +func (o SparseAWSAssetsList) Version() int { + + return 1 +} + +// SparseAWSAsset represents the sparse version of a awsasset. +type SparseAWSAsset struct { + // Identifier of the object. + ID *string `json:"ID,omitempty" msgpack:"ID,omitempty" bson:"-" mapstructure:"ID,omitempty"` + + // The 12 digit ID of the AWS account the resource belongs. + AccountID *string `json:"accountID,omitempty" msgpack:"accountID,omitempty" bson:"accountid,omitempty" mapstructure:"accountID,omitempty"` + + // The ARN of the resource in AWS. + Arn *string `json:"arn,omitempty" msgpack:"arn,omitempty" bson:"arn,omitempty" mapstructure:"arn,omitempty"` + + // Creation date of the object. + CreateTime *time.Time `json:"createTime,omitempty" msgpack:"createTime,omitempty" bson:"createtime,omitempty" mapstructure:"createTime,omitempty"` + + // The JSON-encoded data that represents the resource. + Data *[]byte `json:"data,omitempty" msgpack:"data,omitempty" bson:"data,omitempty" mapstructure:"data,omitempty"` + + // Contextual values that can be used to narrow searching of resources if the + // arn or resourceID are not known. For instance, it could be used to store + // a resource's Subnet or VPC ID. + DenormedFields *[]string `json:"denormedFields,omitempty" msgpack:"denormedFields,omitempty" bson:"denormedfields,omitempty" mapstructure:"denormedFields,omitempty"` + + // The specific kind of the resource. + Kind *AWSAssetKindValue `json:"kind,omitempty" msgpack:"kind,omitempty" bson:"kind,omitempty" mapstructure:"kind,omitempty"` + + // Internal property maintaining migrations information. + MigrationsLog *map[string]string `json:"-" msgpack:"-" bson:"migrationslog,omitempty" mapstructure:"-,omitempty"` + + // The name of the resource. + Name *string `json:"name,omitempty" msgpack:"name,omitempty" bson:"name,omitempty" mapstructure:"name,omitempty"` + + // Namespace tag attached to an entity. + Namespace *string `json:"namespace,omitempty" msgpack:"namespace,omitempty" bson:"namespace,omitempty" mapstructure:"namespace,omitempty"` + + // The resource identifier in PrismaCloud. + PrismaRRN *string `json:"prismaRRN,omitempty" msgpack:"prismaRRN,omitempty" bson:"prismarrn,omitempty" mapstructure:"prismaRRN,omitempty"` + + // The region this resource exists in according to PrismaCloud. Note that the + // resource may exists in a different region as described by AWS. + PrismaRegion *string `json:"prismaRegion,omitempty" msgpack:"prismaRegion,omitempty" bson:"prismaregion,omitempty" mapstructure:"prismaRegion,omitempty"` + + // A resource ID that will mainly be used in RQL queries. + ResourceID *string `json:"resourceID,omitempty" msgpack:"resourceID,omitempty" bson:"resourceid,omitempty" mapstructure:"resourceID,omitempty"` + + // Last update date of the object. + UpdateTime *time.Time `json:"updateTime,omitempty" msgpack:"updateTime,omitempty" bson:"updatetime,omitempty" mapstructure:"updateTime,omitempty"` + + // geographical hash of the data. This is used for sharding and + // georedundancy. + ZHash *int `json:"-" msgpack:"-" bson:"zhash,omitempty" mapstructure:"-,omitempty"` + + // Logical storage zone. Used for sharding. + Zone *int `json:"-" msgpack:"-" bson:"zone,omitempty" mapstructure:"-,omitempty"` + + ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"` +} + +// NewSparseAWSAsset returns a new SparseAWSAsset. +func NewSparseAWSAsset() *SparseAWSAsset { + return &SparseAWSAsset{} +} + +// Identity returns the Identity of the sparse object. +func (o *SparseAWSAsset) Identity() elemental.Identity { + + return AWSAssetIdentity +} + +// Identifier returns the value of the sparse object's unique identifier. +func (o *SparseAWSAsset) Identifier() string { + + if o.ID == nil { + return "" + } + return *o.ID +} + +// SetIdentifier sets the value of the sparse object's unique identifier. +func (o *SparseAWSAsset) SetIdentifier(id string) { + + if id != "" { + o.ID = &id + } else { + o.ID = nil + } +} + +// GetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *SparseAWSAsset) GetBSON() (any, error) { + + if o == nil { + return nil, nil + } + + s := &mongoAttributesSparseAWSAsset{} + + if o.ID != nil { + s.ID = bson.ObjectIdHex(*o.ID) + } + if o.AccountID != nil { + s.AccountID = o.AccountID + } + if o.Arn != nil { + s.Arn = o.Arn + } + if o.CreateTime != nil { + s.CreateTime = o.CreateTime + } + if o.Data != nil { + s.Data = o.Data + } + if o.DenormedFields != nil { + s.DenormedFields = o.DenormedFields + } + if o.Kind != nil { + s.Kind = o.Kind + } + if o.MigrationsLog != nil { + s.MigrationsLog = o.MigrationsLog + } + if o.Name != nil { + s.Name = o.Name + } + if o.Namespace != nil { + s.Namespace = o.Namespace + } + if o.PrismaRRN != nil { + s.PrismaRRN = o.PrismaRRN + } + if o.PrismaRegion != nil { + s.PrismaRegion = o.PrismaRegion + } + if o.ResourceID != nil { + s.ResourceID = o.ResourceID + } + if o.UpdateTime != nil { + s.UpdateTime = o.UpdateTime + } + if o.ZHash != nil { + s.ZHash = o.ZHash + } + if o.Zone != nil { + s.Zone = o.Zone + } + + return s, nil +} + +// SetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *SparseAWSAsset) SetBSON(raw bson.Raw) error { + + if o == nil { + return nil + } + + s := &mongoAttributesSparseAWSAsset{} + if err := raw.Unmarshal(s); err != nil { + return err + } + + id := s.ID.Hex() + o.ID = &id + if s.AccountID != nil { + o.AccountID = s.AccountID + } + if s.Arn != nil { + o.Arn = s.Arn + } + if s.CreateTime != nil { + o.CreateTime = s.CreateTime + } + if s.Data != nil { + o.Data = s.Data + } + if s.DenormedFields != nil { + o.DenormedFields = s.DenormedFields + } + if s.Kind != nil { + o.Kind = s.Kind + } + if s.MigrationsLog != nil { + o.MigrationsLog = s.MigrationsLog + } + if s.Name != nil { + o.Name = s.Name + } + if s.Namespace != nil { + o.Namespace = s.Namespace + } + if s.PrismaRRN != nil { + o.PrismaRRN = s.PrismaRRN + } + if s.PrismaRegion != nil { + o.PrismaRegion = s.PrismaRegion + } + if s.ResourceID != nil { + o.ResourceID = s.ResourceID + } + if s.UpdateTime != nil { + o.UpdateTime = s.UpdateTime + } + if s.ZHash != nil { + o.ZHash = s.ZHash + } + if s.Zone != nil { + o.Zone = s.Zone + } + + return nil +} + +// Version returns the hardcoded version of the model. +func (o *SparseAWSAsset) Version() int { + + return 1 +} + +// ToPlain returns the plain version of the sparse model. +func (o *SparseAWSAsset) ToPlain() elemental.PlainIdentifiable { + + out := NewAWSAsset() + if o.ID != nil { + out.ID = *o.ID + } + if o.AccountID != nil { + out.AccountID = *o.AccountID + } + if o.Arn != nil { + out.Arn = *o.Arn + } + if o.CreateTime != nil { + out.CreateTime = *o.CreateTime + } + if o.Data != nil { + out.Data = *o.Data + } + if o.DenormedFields != nil { + out.DenormedFields = *o.DenormedFields + } + if o.Kind != nil { + out.Kind = *o.Kind + } + if o.MigrationsLog != nil { + out.MigrationsLog = *o.MigrationsLog + } + if o.Name != nil { + out.Name = *o.Name + } + if o.Namespace != nil { + out.Namespace = *o.Namespace + } + if o.PrismaRRN != nil { + out.PrismaRRN = *o.PrismaRRN + } + if o.PrismaRegion != nil { + out.PrismaRegion = *o.PrismaRegion + } + if o.ResourceID != nil { + out.ResourceID = *o.ResourceID + } + if o.UpdateTime != nil { + out.UpdateTime = *o.UpdateTime + } + if o.ZHash != nil { + out.ZHash = *o.ZHash + } + if o.Zone != nil { + out.Zone = *o.Zone + } + + return out +} + +// GetCreateTime returns the CreateTime of the receiver. +func (o *SparseAWSAsset) GetCreateTime() (out time.Time) { + + if o.CreateTime == nil { + return + } + + return *o.CreateTime +} + +// SetCreateTime sets the property CreateTime of the receiver using the address of the given value. +func (o *SparseAWSAsset) SetCreateTime(createTime time.Time) { + + o.CreateTime = &createTime +} + +// GetMigrationsLog returns the MigrationsLog of the receiver. +func (o *SparseAWSAsset) GetMigrationsLog() (out map[string]string) { + + if o.MigrationsLog == nil { + return + } + + return *o.MigrationsLog +} + +// SetMigrationsLog sets the property MigrationsLog of the receiver using the address of the given value. +func (o *SparseAWSAsset) SetMigrationsLog(migrationsLog map[string]string) { + + o.MigrationsLog = &migrationsLog +} + +// GetNamespace returns the Namespace of the receiver. +func (o *SparseAWSAsset) GetNamespace() (out string) { + + if o.Namespace == nil { + return + } + + return *o.Namespace +} + +// SetNamespace sets the property Namespace of the receiver using the address of the given value. +func (o *SparseAWSAsset) SetNamespace(namespace string) { + + o.Namespace = &namespace +} + +// GetUpdateTime returns the UpdateTime of the receiver. +func (o *SparseAWSAsset) GetUpdateTime() (out time.Time) { + + if o.UpdateTime == nil { + return + } + + return *o.UpdateTime +} + +// SetUpdateTime sets the property UpdateTime of the receiver using the address of the given value. +func (o *SparseAWSAsset) SetUpdateTime(updateTime time.Time) { + + o.UpdateTime = &updateTime +} + +// GetZHash returns the ZHash of the receiver. +func (o *SparseAWSAsset) GetZHash() (out int) { + + if o.ZHash == nil { + return + } + + return *o.ZHash +} + +// SetZHash sets the property ZHash of the receiver using the address of the given value. +func (o *SparseAWSAsset) SetZHash(zHash int) { + + o.ZHash = &zHash +} + +// GetZone returns the Zone of the receiver. +func (o *SparseAWSAsset) GetZone() (out int) { + + if o.Zone == nil { + return + } + + return *o.Zone +} + +// SetZone sets the property Zone of the receiver using the address of the given value. +func (o *SparseAWSAsset) SetZone(zone int) { + + o.Zone = &zone +} + +// DeepCopy returns a deep copy if the SparseAWSAsset. +func (o *SparseAWSAsset) DeepCopy() *SparseAWSAsset { + + if o == nil { + return nil + } + + out := &SparseAWSAsset{} + o.DeepCopyInto(out) + + return out +} + +// DeepCopyInto copies the receiver into the given *SparseAWSAsset. +func (o *SparseAWSAsset) DeepCopyInto(out *SparseAWSAsset) { + + target, err := copystructure.Copy(o) + if err != nil { + panic(fmt.Sprintf("Unable to deepcopy SparseAWSAsset: %s", err)) + } + + *out = *target.(*SparseAWSAsset) +} + +type mongoAttributesAWSAsset struct { + ID bson.ObjectId `bson:"_id,omitempty"` + AccountID string `bson:"accountid,omitempty"` + Arn string `bson:"arn"` + CreateTime time.Time `bson:"createtime"` + Data []byte `bson:"data"` + DenormedFields []string `bson:"denormedfields"` + Kind AWSAssetKindValue `bson:"kind"` + MigrationsLog map[string]string `bson:"migrationslog,omitempty"` + Name string `bson:"name"` + Namespace string `bson:"namespace"` + PrismaRRN string `bson:"prismarrn,omitempty"` + PrismaRegion string `bson:"prismaregion"` + ResourceID string `bson:"resourceid"` + UpdateTime time.Time `bson:"updatetime"` + ZHash int `bson:"zhash"` + Zone int `bson:"zone"` +} +type mongoAttributesSparseAWSAsset struct { + ID bson.ObjectId `bson:"_id,omitempty"` + AccountID *string `bson:"accountid,omitempty"` + Arn *string `bson:"arn,omitempty"` + CreateTime *time.Time `bson:"createtime,omitempty"` + Data *[]byte `bson:"data,omitempty"` + DenormedFields *[]string `bson:"denormedfields,omitempty"` + Kind *AWSAssetKindValue `bson:"kind,omitempty"` + MigrationsLog *map[string]string `bson:"migrationslog,omitempty"` + Name *string `bson:"name,omitempty"` + Namespace *string `bson:"namespace,omitempty"` + PrismaRRN *string `bson:"prismarrn,omitempty"` + PrismaRegion *string `bson:"prismaregion,omitempty"` + ResourceID *string `bson:"resourceid,omitempty"` + UpdateTime *time.Time `bson:"updatetime,omitempty"` + ZHash *int `bson:"zhash,omitempty"` + Zone *int `bson:"zone,omitempty"` +} diff --git a/awsresource.go b/awsresource.go new file mode 100644 index 000000000..55abbb730 --- /dev/null +++ b/awsresource.go @@ -0,0 +1,1515 @@ +// Code generated by elegen. DO NOT EDIT. +// Source: go.aporeto.io/elemental (templates/model.gotpl) + +package gaia + +import ( + "fmt" + "time" + + "github.com/globalsign/mgo/bson" + "github.com/mitchellh/copystructure" + "go.aporeto.io/elemental" +) + +// AWSResourceKindValue represents the possible values for attribute "kind". +type AWSResourceKindValue string + +const ( + // AWSResourceKindInstance represents the value Instance. + AWSResourceKindInstance AWSResourceKindValue = "Instance" + + // AWSResourceKindInternetGateway represents the value InternetGateway. + AWSResourceKindInternetGateway AWSResourceKindValue = "InternetGateway" + + // AWSResourceKindNetworkACL represents the value NetworkACL. + AWSResourceKindNetworkACL AWSResourceKindValue = "NetworkACL" + + // AWSResourceKindNetworkInterface represents the value NetworkInterface. + AWSResourceKindNetworkInterface AWSResourceKindValue = "NetworkInterface" + + // AWSResourceKindPending represents the value Pending. + AWSResourceKindPending AWSResourceKindValue = "Pending" + + // AWSResourceKindSecurityGroup represents the value SecurityGroup. + AWSResourceKindSecurityGroup AWSResourceKindValue = "SecurityGroup" + + // AWSResourceKindSubnet represents the value Subnet. + AWSResourceKindSubnet AWSResourceKindValue = "Subnet" + + // AWSResourceKindVPC represents the value VPC. + AWSResourceKindVPC AWSResourceKindValue = "VPC" +) + +// AWSResourceIdentity represents the Identity of the object. +var AWSResourceIdentity = elemental.Identity{ + Name: "awsresource", + Category: "awsresources", + Package: "pandemona", + Private: true, +} + +// AWSResourcesList represents a list of AWSResources +type AWSResourcesList []*AWSResource + +// Identity returns the identity of the objects in the list. +func (o AWSResourcesList) Identity() elemental.Identity { + + return AWSResourceIdentity +} + +// Copy returns a pointer to a copy the AWSResourcesList. +func (o AWSResourcesList) Copy() elemental.Identifiables { + + out := append(AWSResourcesList{}, o...) + return &out +} + +// Append appends the objects to the a new copy of the AWSResourcesList. +func (o AWSResourcesList) Append(objects ...elemental.Identifiable) elemental.Identifiables { + + out := append(AWSResourcesList{}, o...) + for _, obj := range objects { + out = append(out, obj.(*AWSResource)) + } + + return out +} + +// List converts the object to an elemental.IdentifiablesList. +func (o AWSResourcesList) List() elemental.IdentifiablesList { + + out := make(elemental.IdentifiablesList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i] + } + + return out +} + +// DefaultOrder returns the default ordering fields of the content. +func (o AWSResourcesList) DefaultOrder() []string { + + return []string{} +} + +// ToSparse returns the AWSResourcesList converted to SparseAWSResourcesList. +// Objects in the list will only contain the given fields. No field means entire field set. +func (o AWSResourcesList) ToSparse(fields ...string) elemental.Identifiables { + + out := make(SparseAWSResourcesList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i].ToSparse(fields...).(*SparseAWSResource) + } + + return out +} + +// Version returns the version of the content. +func (o AWSResourcesList) Version() int { + + return 1 +} + +// AWSResource represents the model of a awsresource +type AWSResource struct { + // Identifier of the object. + ID string `json:"ID" msgpack:"ID" bson:"-" mapstructure:"ID,omitempty"` + + // The 12 digit ID of the AWS account the resource belongs. + AccountID string `json:"accountID,omitempty" msgpack:"accountID,omitempty" bson:"accountid,omitempty" mapstructure:"accountID,omitempty"` + + // The ARN of the resource in AWS. + Arn string `json:"arn" msgpack:"arn" bson:"arn" mapstructure:"arn,omitempty"` + + // Creation date of the object. + CreateTime time.Time `json:"createTime" msgpack:"createTime" bson:"createtime" mapstructure:"createTime,omitempty"` + + // The JSON-encoded data that represents the resource. + Data []byte `json:"data" msgpack:"data" bson:"data" mapstructure:"data,omitempty"` + + // Contextual values that can be used to narrow searching of resources if the + // arn or resourceID are not known. For instance, it could be used to store + // a resource's Subnet or VPC ID. + DenormedFields []string `json:"denormedFields" msgpack:"denormedFields" bson:"denormedfields" mapstructure:"denormedFields,omitempty"` + + // The specific kind of the resource. + Kind AWSResourceKindValue `json:"kind" msgpack:"kind" bson:"kind" mapstructure:"kind,omitempty"` + + // Internal property maintaining migrations information. + MigrationsLog map[string]string `json:"-" msgpack:"-" bson:"migrationslog,omitempty" mapstructure:"-,omitempty"` + + // The name of the resource. + Name string `json:"name" msgpack:"name" bson:"name" mapstructure:"name,omitempty"` + + // Namespace tag attached to an entity. + Namespace string `json:"namespace" msgpack:"namespace" bson:"namespace" mapstructure:"namespace,omitempty"` + + // The resource identifier in PrismaCloud. + PrismaRRN string `json:"prismaRRN,omitempty" msgpack:"prismaRRN,omitempty" bson:"prismarrn,omitempty" mapstructure:"prismaRRN,omitempty"` + + // The region this resource exists in according to PrismaCloud. Note that the + // resource may exists in a different region as described by AWS. + PrismaRegion string `json:"prismaRegion" msgpack:"prismaRegion" bson:"prismaregion" mapstructure:"prismaRegion,omitempty"` + + // A resource ID that will mainly be used in RQL queries. + ResourceID string `json:"resourceID" msgpack:"resourceID" bson:"resourceid" mapstructure:"resourceID,omitempty"` + + // Last update date of the object. + UpdateTime time.Time `json:"updateTime" msgpack:"updateTime" bson:"updatetime" mapstructure:"updateTime,omitempty"` + + // geographical hash of the data. This is used for sharding and + // georedundancy. + ZHash int `json:"-" msgpack:"-" bson:"zhash" mapstructure:"-,omitempty"` + + // Logical storage zone. Used for sharding. + Zone int `json:"-" msgpack:"-" bson:"zone" mapstructure:"-,omitempty"` + + ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"` +} + +// NewAWSResource returns a new *AWSResource +func NewAWSResource() *AWSResource { + + return &AWSResource{ + ModelVersion: 1, + Data: []byte{}, + DenormedFields: []string{}, + Kind: AWSResourceKindPending, + MigrationsLog: map[string]string{}, + } +} + +// Identity returns the Identity of the object. +func (o *AWSResource) Identity() elemental.Identity { + + return AWSResourceIdentity +} + +// Identifier returns the value of the object's unique identifier. +func (o *AWSResource) Identifier() string { + + return o.ID +} + +// SetIdentifier sets the value of the object's unique identifier. +func (o *AWSResource) SetIdentifier(id string) { + + o.ID = id +} + +// GetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *AWSResource) GetBSON() (any, error) { + + if o == nil { + return nil, nil + } + + s := &mongoAttributesAWSResource{} + + if o.ID != "" { + s.ID = bson.ObjectIdHex(o.ID) + } + s.AccountID = o.AccountID + s.Arn = o.Arn + s.CreateTime = o.CreateTime + s.Data = o.Data + s.DenormedFields = o.DenormedFields + s.Kind = o.Kind + s.MigrationsLog = o.MigrationsLog + s.Name = o.Name + s.Namespace = o.Namespace + s.PrismaRRN = o.PrismaRRN + s.PrismaRegion = o.PrismaRegion + s.ResourceID = o.ResourceID + s.UpdateTime = o.UpdateTime + s.ZHash = o.ZHash + s.Zone = o.Zone + + return s, nil +} + +// SetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *AWSResource) SetBSON(raw bson.Raw) error { + + if o == nil { + return nil + } + + s := &mongoAttributesAWSResource{} + if err := raw.Unmarshal(s); err != nil { + return err + } + + o.ID = s.ID.Hex() + o.AccountID = s.AccountID + o.Arn = s.Arn + o.CreateTime = s.CreateTime + o.Data = s.Data + o.DenormedFields = s.DenormedFields + o.Kind = s.Kind + o.MigrationsLog = s.MigrationsLog + o.Name = s.Name + o.Namespace = s.Namespace + o.PrismaRRN = s.PrismaRRN + o.PrismaRegion = s.PrismaRegion + o.ResourceID = s.ResourceID + o.UpdateTime = s.UpdateTime + o.ZHash = s.ZHash + o.Zone = s.Zone + + return nil +} + +// Version returns the hardcoded version of the model. +func (o *AWSResource) Version() int { + + return 1 +} + +// BleveType implements the bleve.Classifier Interface. +func (o *AWSResource) BleveType() string { + + return "awsresource" +} + +// DefaultOrder returns the list of default ordering fields. +func (o *AWSResource) DefaultOrder() []string { + + return []string{} +} + +// Doc returns the documentation for the object +func (o *AWSResource) Doc() string { + + return `Represents a AWS cloud resource such as a virtual machine.` +} + +func (o *AWSResource) String() string { + + return fmt.Sprintf("<%s:%s>", o.Identity().Name, o.Identifier()) +} + +// GetCreateTime returns the CreateTime of the receiver. +func (o *AWSResource) GetCreateTime() time.Time { + + return o.CreateTime +} + +// SetCreateTime sets the property CreateTime of the receiver using the given value. +func (o *AWSResource) SetCreateTime(createTime time.Time) { + + o.CreateTime = createTime +} + +// GetMigrationsLog returns the MigrationsLog of the receiver. +func (o *AWSResource) GetMigrationsLog() map[string]string { + + return o.MigrationsLog +} + +// SetMigrationsLog sets the property MigrationsLog of the receiver using the given value. +func (o *AWSResource) SetMigrationsLog(migrationsLog map[string]string) { + + o.MigrationsLog = migrationsLog +} + +// GetNamespace returns the Namespace of the receiver. +func (o *AWSResource) GetNamespace() string { + + return o.Namespace +} + +// SetNamespace sets the property Namespace of the receiver using the given value. +func (o *AWSResource) SetNamespace(namespace string) { + + o.Namespace = namespace +} + +// GetUpdateTime returns the UpdateTime of the receiver. +func (o *AWSResource) GetUpdateTime() time.Time { + + return o.UpdateTime +} + +// SetUpdateTime sets the property UpdateTime of the receiver using the given value. +func (o *AWSResource) SetUpdateTime(updateTime time.Time) { + + o.UpdateTime = updateTime +} + +// GetZHash returns the ZHash of the receiver. +func (o *AWSResource) GetZHash() int { + + return o.ZHash +} + +// SetZHash sets the property ZHash of the receiver using the given value. +func (o *AWSResource) SetZHash(zHash int) { + + o.ZHash = zHash +} + +// GetZone returns the Zone of the receiver. +func (o *AWSResource) GetZone() int { + + return o.Zone +} + +// SetZone sets the property Zone of the receiver using the given value. +func (o *AWSResource) SetZone(zone int) { + + o.Zone = zone +} + +// ToSparse returns the sparse version of the model. +// The returned object will only contain the given fields. No field means entire field set. +func (o *AWSResource) ToSparse(fields ...string) elemental.SparseIdentifiable { + + if len(fields) == 0 { + // nolint: goimports + return &SparseAWSResource{ + ID: &o.ID, + AccountID: &o.AccountID, + Arn: &o.Arn, + CreateTime: &o.CreateTime, + Data: &o.Data, + DenormedFields: &o.DenormedFields, + Kind: &o.Kind, + MigrationsLog: &o.MigrationsLog, + Name: &o.Name, + Namespace: &o.Namespace, + PrismaRRN: &o.PrismaRRN, + PrismaRegion: &o.PrismaRegion, + ResourceID: &o.ResourceID, + UpdateTime: &o.UpdateTime, + ZHash: &o.ZHash, + Zone: &o.Zone, + } + } + + sp := &SparseAWSResource{} + for _, f := range fields { + switch f { + case "ID": + sp.ID = &(o.ID) + case "accountID": + sp.AccountID = &(o.AccountID) + case "arn": + sp.Arn = &(o.Arn) + case "createTime": + sp.CreateTime = &(o.CreateTime) + case "data": + sp.Data = &(o.Data) + case "denormedFields": + sp.DenormedFields = &(o.DenormedFields) + case "kind": + sp.Kind = &(o.Kind) + case "migrationsLog": + sp.MigrationsLog = &(o.MigrationsLog) + case "name": + sp.Name = &(o.Name) + case "namespace": + sp.Namespace = &(o.Namespace) + case "prismaRRN": + sp.PrismaRRN = &(o.PrismaRRN) + case "prismaRegion": + sp.PrismaRegion = &(o.PrismaRegion) + case "resourceID": + sp.ResourceID = &(o.ResourceID) + case "updateTime": + sp.UpdateTime = &(o.UpdateTime) + case "zHash": + sp.ZHash = &(o.ZHash) + case "zone": + sp.Zone = &(o.Zone) + } + } + + return sp +} + +// Patch apply the non nil value of a *SparseAWSResource to the object. +func (o *AWSResource) Patch(sparse elemental.SparseIdentifiable) { + if !sparse.Identity().IsEqual(o.Identity()) { + panic("cannot patch from a parse with different identity") + } + + so := sparse.(*SparseAWSResource) + if so.ID != nil { + o.ID = *so.ID + } + if so.AccountID != nil { + o.AccountID = *so.AccountID + } + if so.Arn != nil { + o.Arn = *so.Arn + } + if so.CreateTime != nil { + o.CreateTime = *so.CreateTime + } + if so.Data != nil { + o.Data = *so.Data + } + if so.DenormedFields != nil { + o.DenormedFields = *so.DenormedFields + } + if so.Kind != nil { + o.Kind = *so.Kind + } + if so.MigrationsLog != nil { + o.MigrationsLog = *so.MigrationsLog + } + if so.Name != nil { + o.Name = *so.Name + } + if so.Namespace != nil { + o.Namespace = *so.Namespace + } + if so.PrismaRRN != nil { + o.PrismaRRN = *so.PrismaRRN + } + if so.PrismaRegion != nil { + o.PrismaRegion = *so.PrismaRegion + } + if so.ResourceID != nil { + o.ResourceID = *so.ResourceID + } + if so.UpdateTime != nil { + o.UpdateTime = *so.UpdateTime + } + if so.ZHash != nil { + o.ZHash = *so.ZHash + } + if so.Zone != nil { + o.Zone = *so.Zone + } +} + +// DeepCopy returns a deep copy if the AWSResource. +func (o *AWSResource) DeepCopy() *AWSResource { + + if o == nil { + return nil + } + + out := &AWSResource{} + o.DeepCopyInto(out) + + return out +} + +// DeepCopyInto copies the receiver into the given *AWSResource. +func (o *AWSResource) DeepCopyInto(out *AWSResource) { + + target, err := copystructure.Copy(o) + if err != nil { + panic(fmt.Sprintf("Unable to deepcopy AWSResource: %s", err)) + } + + *out = *target.(*AWSResource) +} + +// Validate valides the current information stored into the structure. +func (o *AWSResource) Validate() error { + + errors := elemental.Errors{} + requiredErrors := elemental.Errors{} + + if err := elemental.ValidateRequiredExternal("data", o.Data); err != nil { + requiredErrors = requiredErrors.Append(err) + } + + if err := elemental.ValidateStringInList("kind", string(o.Kind), []string{"Pending", "Instance", "NetworkInterface", "VPC", "Subnet", "NetworkACL", "InternetGateway", "SecurityGroup"}, true); err != nil { + errors = errors.Append(err) + } + + if len(requiredErrors) > 0 { + return requiredErrors + } + + if len(errors) > 0 { + return errors + } + + return nil +} + +// SpecificationForAttribute returns the AttributeSpecification for the given attribute name key. +func (*AWSResource) SpecificationForAttribute(name string) elemental.AttributeSpecification { + + if v, ok := AWSResourceAttributesMap[name]; ok { + return v + } + + // We could not find it, so let's check on the lower case indexed spec map + return AWSResourceLowerCaseAttributesMap[name] +} + +// AttributeSpecifications returns the full attribute specifications map. +func (*AWSResource) AttributeSpecifications() map[string]elemental.AttributeSpecification { + + return AWSResourceAttributesMap +} + +// ValueForAttribute returns the value for the given attribute. +// This is a very advanced function that you should not need but in some +// very specific use cases. +func (o *AWSResource) ValueForAttribute(name string) any { + + switch name { + case "ID": + return o.ID + case "accountID": + return o.AccountID + case "arn": + return o.Arn + case "createTime": + return o.CreateTime + case "data": + return o.Data + case "denormedFields": + return o.DenormedFields + case "kind": + return o.Kind + case "migrationsLog": + return o.MigrationsLog + case "name": + return o.Name + case "namespace": + return o.Namespace + case "prismaRRN": + return o.PrismaRRN + case "prismaRegion": + return o.PrismaRegion + case "resourceID": + return o.ResourceID + case "updateTime": + return o.UpdateTime + case "zHash": + return o.ZHash + case "zone": + return o.Zone + } + + return nil +} + +// AWSResourceAttributesMap represents the map of attribute for AWSResource. +var AWSResourceAttributesMap = map[string]elemental.AttributeSpecification{ + "ID": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "_id", + ConvertedName: "ID", + Description: `Identifier of the object.`, + Exposed: true, + Filterable: true, + Identifier: true, + Name: "ID", + Orderable: true, + ReadOnly: true, + Stored: true, + Type: "string", + }, + "AccountID": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "accountid", + ConvertedName: "AccountID", + Description: `The 12 digit ID of the AWS account the resource belongs.`, + Exposed: true, + Name: "accountID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "Arn": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "arn", + ConvertedName: "Arn", + Description: `The ARN of the resource in AWS.`, + Exposed: true, + Name: "arn", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "CreateTime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "createtime", + ConvertedName: "CreateTime", + Description: `Creation date of the object.`, + Exposed: true, + Getter: true, + Name: "createTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "Data": { + AllowedChoices: []string{}, + BSONFieldName: "data", + ConvertedName: "Data", + Description: `The JSON-encoded data that represents the resource.`, + Exposed: true, + Name: "data", + Required: true, + Stored: true, + SubType: "[]byte", + Type: "external", + }, + "DenormedFields": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "denormedfields", + ConvertedName: "DenormedFields", + Description: `Contextual values that can be used to narrow searching of resources if the +arn or resourceID are not known. For instance, it could be used to store +a resource's Subnet or VPC ID.`, + Exposed: true, + Name: "denormedFields", + ReadOnly: true, + Stored: true, + SubType: "string", + Type: "list", + }, + "Kind": { + AllowedChoices: []string{"Pending", "Instance", "NetworkInterface", "VPC", "Subnet", "NetworkACL", "InternetGateway", "SecurityGroup"}, + Autogenerated: true, + BSONFieldName: "kind", + ConvertedName: "Kind", + DefaultValue: AWSResourceKindPending, + Description: `The specific kind of the resource.`, + Exposed: true, + Name: "kind", + ReadOnly: true, + Stored: true, + Type: "enum", + }, + "MigrationsLog": { + AllowedChoices: []string{}, + BSONFieldName: "migrationslog", + ConvertedName: "MigrationsLog", + Description: `Internal property maintaining migrations information.`, + Getter: true, + Name: "migrationsLog", + Setter: true, + Stored: true, + SubType: "map[string]string", + Type: "external", + }, + "Name": { + AllowedChoices: []string{}, + BSONFieldName: "name", + ConvertedName: "Name", + Description: `The name of the resource.`, + Exposed: true, + Name: "name", + Stored: true, + Type: "string", + }, + "Namespace": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "namespace", + ConvertedName: "Namespace", + Description: `Namespace tag attached to an entity.`, + Exposed: true, + Filterable: true, + Getter: true, + Name: "namespace", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "string", + }, + "PrismaRRN": { + AllowedChoices: []string{}, + BSONFieldName: "prismarrn", + ConvertedName: "PrismaRRN", + Description: `The resource identifier in PrismaCloud.`, + Exposed: true, + Name: "prismaRRN", + Stored: true, + Type: "string", + }, + "PrismaRegion": { + AllowedChoices: []string{}, + BSONFieldName: "prismaregion", + ConvertedName: "PrismaRegion", + Description: `The region this resource exists in according to PrismaCloud. Note that the +resource may exists in a different region as described by AWS.`, + Exposed: true, + Name: "prismaRegion", + Stored: true, + Type: "string", + }, + "ResourceID": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "resourceid", + ConvertedName: "ResourceID", + Description: `A resource ID that will mainly be used in RQL queries.`, + Exposed: true, + Name: "resourceID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "UpdateTime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "updatetime", + ConvertedName: "UpdateTime", + Description: `Last update date of the object.`, + Exposed: true, + Getter: true, + Name: "updateTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "ZHash": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zhash", + ConvertedName: "ZHash", + Description: `geographical hash of the data. This is used for sharding and +georedundancy.`, + Getter: true, + Name: "zHash", + ReadOnly: true, + Setter: true, + Stored: true, + Type: "integer", + }, + "Zone": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zone", + ConvertedName: "Zone", + Description: `Logical storage zone. Used for sharding.`, + Getter: true, + Name: "zone", + ReadOnly: true, + Setter: true, + Stored: true, + Transient: true, + Type: "integer", + }, +} + +// AWSResourceLowerCaseAttributesMap represents the map of attribute for AWSResource. +var AWSResourceLowerCaseAttributesMap = map[string]elemental.AttributeSpecification{ + "id": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "_id", + ConvertedName: "ID", + Description: `Identifier of the object.`, + Exposed: true, + Filterable: true, + Identifier: true, + Name: "ID", + Orderable: true, + ReadOnly: true, + Stored: true, + Type: "string", + }, + "accountid": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "accountid", + ConvertedName: "AccountID", + Description: `The 12 digit ID of the AWS account the resource belongs.`, + Exposed: true, + Name: "accountID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "arn": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "arn", + ConvertedName: "Arn", + Description: `The ARN of the resource in AWS.`, + Exposed: true, + Name: "arn", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "createtime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "createtime", + ConvertedName: "CreateTime", + Description: `Creation date of the object.`, + Exposed: true, + Getter: true, + Name: "createTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "data": { + AllowedChoices: []string{}, + BSONFieldName: "data", + ConvertedName: "Data", + Description: `The JSON-encoded data that represents the resource.`, + Exposed: true, + Name: "data", + Required: true, + Stored: true, + SubType: "[]byte", + Type: "external", + }, + "denormedfields": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "denormedfields", + ConvertedName: "DenormedFields", + Description: `Contextual values that can be used to narrow searching of resources if the +arn or resourceID are not known. For instance, it could be used to store +a resource's Subnet or VPC ID.`, + Exposed: true, + Name: "denormedFields", + ReadOnly: true, + Stored: true, + SubType: "string", + Type: "list", + }, + "kind": { + AllowedChoices: []string{"Pending", "Instance", "NetworkInterface", "VPC", "Subnet", "NetworkACL", "InternetGateway", "SecurityGroup"}, + Autogenerated: true, + BSONFieldName: "kind", + ConvertedName: "Kind", + DefaultValue: AWSResourceKindPending, + Description: `The specific kind of the resource.`, + Exposed: true, + Name: "kind", + ReadOnly: true, + Stored: true, + Type: "enum", + }, + "migrationslog": { + AllowedChoices: []string{}, + BSONFieldName: "migrationslog", + ConvertedName: "MigrationsLog", + Description: `Internal property maintaining migrations information.`, + Getter: true, + Name: "migrationsLog", + Setter: true, + Stored: true, + SubType: "map[string]string", + Type: "external", + }, + "name": { + AllowedChoices: []string{}, + BSONFieldName: "name", + ConvertedName: "Name", + Description: `The name of the resource.`, + Exposed: true, + Name: "name", + Stored: true, + Type: "string", + }, + "namespace": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "namespace", + ConvertedName: "Namespace", + Description: `Namespace tag attached to an entity.`, + Exposed: true, + Filterable: true, + Getter: true, + Name: "namespace", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "string", + }, + "prismarrn": { + AllowedChoices: []string{}, + BSONFieldName: "prismarrn", + ConvertedName: "PrismaRRN", + Description: `The resource identifier in PrismaCloud.`, + Exposed: true, + Name: "prismaRRN", + Stored: true, + Type: "string", + }, + "prismaregion": { + AllowedChoices: []string{}, + BSONFieldName: "prismaregion", + ConvertedName: "PrismaRegion", + Description: `The region this resource exists in according to PrismaCloud. Note that the +resource may exists in a different region as described by AWS.`, + Exposed: true, + Name: "prismaRegion", + Stored: true, + Type: "string", + }, + "resourceid": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "resourceid", + ConvertedName: "ResourceID", + Description: `A resource ID that will mainly be used in RQL queries.`, + Exposed: true, + Name: "resourceID", + ReadOnly: true, + Stored: true, + Type: "string", + }, + "updatetime": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "updatetime", + ConvertedName: "UpdateTime", + Description: `Last update date of the object.`, + Exposed: true, + Getter: true, + Name: "updateTime", + Orderable: true, + ReadOnly: true, + Setter: true, + Stored: true, + Type: "time", + }, + "zhash": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zhash", + ConvertedName: "ZHash", + Description: `geographical hash of the data. This is used for sharding and +georedundancy.`, + Getter: true, + Name: "zHash", + ReadOnly: true, + Setter: true, + Stored: true, + Type: "integer", + }, + "zone": { + AllowedChoices: []string{}, + Autogenerated: true, + BSONFieldName: "zone", + ConvertedName: "Zone", + Description: `Logical storage zone. Used for sharding.`, + Getter: true, + Name: "zone", + ReadOnly: true, + Setter: true, + Stored: true, + Transient: true, + Type: "integer", + }, +} + +// SparseAWSResourcesList represents a list of SparseAWSResources +type SparseAWSResourcesList []*SparseAWSResource + +// Identity returns the identity of the objects in the list. +func (o SparseAWSResourcesList) Identity() elemental.Identity { + + return AWSResourceIdentity +} + +// Copy returns a pointer to a copy the SparseAWSResourcesList. +func (o SparseAWSResourcesList) Copy() elemental.Identifiables { + + copy := append(SparseAWSResourcesList{}, o...) + return © +} + +// Append appends the objects to the a new copy of the SparseAWSResourcesList. +func (o SparseAWSResourcesList) Append(objects ...elemental.Identifiable) elemental.Identifiables { + + out := append(SparseAWSResourcesList{}, o...) + for _, obj := range objects { + out = append(out, obj.(*SparseAWSResource)) + } + + return out +} + +// List converts the object to an elemental.IdentifiablesList. +func (o SparseAWSResourcesList) List() elemental.IdentifiablesList { + + out := make(elemental.IdentifiablesList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i] + } + + return out +} + +// DefaultOrder returns the default ordering fields of the content. +func (o SparseAWSResourcesList) DefaultOrder() []string { + + return []string{} +} + +// ToPlain returns the SparseAWSResourcesList converted to AWSResourcesList. +func (o SparseAWSResourcesList) ToPlain() elemental.IdentifiablesList { + + out := make(elemental.IdentifiablesList, len(o)) + for i := 0; i < len(o); i++ { + out[i] = o[i].ToPlain() + } + + return out +} + +// Version returns the version of the content. +func (o SparseAWSResourcesList) Version() int { + + return 1 +} + +// SparseAWSResource represents the sparse version of a awsresource. +type SparseAWSResource struct { + // Identifier of the object. + ID *string `json:"ID,omitempty" msgpack:"ID,omitempty" bson:"-" mapstructure:"ID,omitempty"` + + // The 12 digit ID of the AWS account the resource belongs. + AccountID *string `json:"accountID,omitempty" msgpack:"accountID,omitempty" bson:"accountid,omitempty" mapstructure:"accountID,omitempty"` + + // The ARN of the resource in AWS. + Arn *string `json:"arn,omitempty" msgpack:"arn,omitempty" bson:"arn,omitempty" mapstructure:"arn,omitempty"` + + // Creation date of the object. + CreateTime *time.Time `json:"createTime,omitempty" msgpack:"createTime,omitempty" bson:"createtime,omitempty" mapstructure:"createTime,omitempty"` + + // The JSON-encoded data that represents the resource. + Data *[]byte `json:"data,omitempty" msgpack:"data,omitempty" bson:"data,omitempty" mapstructure:"data,omitempty"` + + // Contextual values that can be used to narrow searching of resources if the + // arn or resourceID are not known. For instance, it could be used to store + // a resource's Subnet or VPC ID. + DenormedFields *[]string `json:"denormedFields,omitempty" msgpack:"denormedFields,omitempty" bson:"denormedfields,omitempty" mapstructure:"denormedFields,omitempty"` + + // The specific kind of the resource. + Kind *AWSResourceKindValue `json:"kind,omitempty" msgpack:"kind,omitempty" bson:"kind,omitempty" mapstructure:"kind,omitempty"` + + // Internal property maintaining migrations information. + MigrationsLog *map[string]string `json:"-" msgpack:"-" bson:"migrationslog,omitempty" mapstructure:"-,omitempty"` + + // The name of the resource. + Name *string `json:"name,omitempty" msgpack:"name,omitempty" bson:"name,omitempty" mapstructure:"name,omitempty"` + + // Namespace tag attached to an entity. + Namespace *string `json:"namespace,omitempty" msgpack:"namespace,omitempty" bson:"namespace,omitempty" mapstructure:"namespace,omitempty"` + + // The resource identifier in PrismaCloud. + PrismaRRN *string `json:"prismaRRN,omitempty" msgpack:"prismaRRN,omitempty" bson:"prismarrn,omitempty" mapstructure:"prismaRRN,omitempty"` + + // The region this resource exists in according to PrismaCloud. Note that the + // resource may exists in a different region as described by AWS. + PrismaRegion *string `json:"prismaRegion,omitempty" msgpack:"prismaRegion,omitempty" bson:"prismaregion,omitempty" mapstructure:"prismaRegion,omitempty"` + + // A resource ID that will mainly be used in RQL queries. + ResourceID *string `json:"resourceID,omitempty" msgpack:"resourceID,omitempty" bson:"resourceid,omitempty" mapstructure:"resourceID,omitempty"` + + // Last update date of the object. + UpdateTime *time.Time `json:"updateTime,omitempty" msgpack:"updateTime,omitempty" bson:"updatetime,omitempty" mapstructure:"updateTime,omitempty"` + + // geographical hash of the data. This is used for sharding and + // georedundancy. + ZHash *int `json:"-" msgpack:"-" bson:"zhash,omitempty" mapstructure:"-,omitempty"` + + // Logical storage zone. Used for sharding. + Zone *int `json:"-" msgpack:"-" bson:"zone,omitempty" mapstructure:"-,omitempty"` + + ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"` +} + +// NewSparseAWSResource returns a new SparseAWSResource. +func NewSparseAWSResource() *SparseAWSResource { + return &SparseAWSResource{} +} + +// Identity returns the Identity of the sparse object. +func (o *SparseAWSResource) Identity() elemental.Identity { + + return AWSResourceIdentity +} + +// Identifier returns the value of the sparse object's unique identifier. +func (o *SparseAWSResource) Identifier() string { + + if o.ID == nil { + return "" + } + return *o.ID +} + +// SetIdentifier sets the value of the sparse object's unique identifier. +func (o *SparseAWSResource) SetIdentifier(id string) { + + if id != "" { + o.ID = &id + } else { + o.ID = nil + } +} + +// GetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *SparseAWSResource) GetBSON() (any, error) { + + if o == nil { + return nil, nil + } + + s := &mongoAttributesSparseAWSResource{} + + if o.ID != nil { + s.ID = bson.ObjectIdHex(*o.ID) + } + if o.AccountID != nil { + s.AccountID = o.AccountID + } + if o.Arn != nil { + s.Arn = o.Arn + } + if o.CreateTime != nil { + s.CreateTime = o.CreateTime + } + if o.Data != nil { + s.Data = o.Data + } + if o.DenormedFields != nil { + s.DenormedFields = o.DenormedFields + } + if o.Kind != nil { + s.Kind = o.Kind + } + if o.MigrationsLog != nil { + s.MigrationsLog = o.MigrationsLog + } + if o.Name != nil { + s.Name = o.Name + } + if o.Namespace != nil { + s.Namespace = o.Namespace + } + if o.PrismaRRN != nil { + s.PrismaRRN = o.PrismaRRN + } + if o.PrismaRegion != nil { + s.PrismaRegion = o.PrismaRegion + } + if o.ResourceID != nil { + s.ResourceID = o.ResourceID + } + if o.UpdateTime != nil { + s.UpdateTime = o.UpdateTime + } + if o.ZHash != nil { + s.ZHash = o.ZHash + } + if o.Zone != nil { + s.Zone = o.Zone + } + + return s, nil +} + +// SetBSON implements the bson marshaling interface. +// This is used to transparently convert ID to MongoDBID as ObectID. +func (o *SparseAWSResource) SetBSON(raw bson.Raw) error { + + if o == nil { + return nil + } + + s := &mongoAttributesSparseAWSResource{} + if err := raw.Unmarshal(s); err != nil { + return err + } + + id := s.ID.Hex() + o.ID = &id + if s.AccountID != nil { + o.AccountID = s.AccountID + } + if s.Arn != nil { + o.Arn = s.Arn + } + if s.CreateTime != nil { + o.CreateTime = s.CreateTime + } + if s.Data != nil { + o.Data = s.Data + } + if s.DenormedFields != nil { + o.DenormedFields = s.DenormedFields + } + if s.Kind != nil { + o.Kind = s.Kind + } + if s.MigrationsLog != nil { + o.MigrationsLog = s.MigrationsLog + } + if s.Name != nil { + o.Name = s.Name + } + if s.Namespace != nil { + o.Namespace = s.Namespace + } + if s.PrismaRRN != nil { + o.PrismaRRN = s.PrismaRRN + } + if s.PrismaRegion != nil { + o.PrismaRegion = s.PrismaRegion + } + if s.ResourceID != nil { + o.ResourceID = s.ResourceID + } + if s.UpdateTime != nil { + o.UpdateTime = s.UpdateTime + } + if s.ZHash != nil { + o.ZHash = s.ZHash + } + if s.Zone != nil { + o.Zone = s.Zone + } + + return nil +} + +// Version returns the hardcoded version of the model. +func (o *SparseAWSResource) Version() int { + + return 1 +} + +// ToPlain returns the plain version of the sparse model. +func (o *SparseAWSResource) ToPlain() elemental.PlainIdentifiable { + + out := NewAWSResource() + if o.ID != nil { + out.ID = *o.ID + } + if o.AccountID != nil { + out.AccountID = *o.AccountID + } + if o.Arn != nil { + out.Arn = *o.Arn + } + if o.CreateTime != nil { + out.CreateTime = *o.CreateTime + } + if o.Data != nil { + out.Data = *o.Data + } + if o.DenormedFields != nil { + out.DenormedFields = *o.DenormedFields + } + if o.Kind != nil { + out.Kind = *o.Kind + } + if o.MigrationsLog != nil { + out.MigrationsLog = *o.MigrationsLog + } + if o.Name != nil { + out.Name = *o.Name + } + if o.Namespace != nil { + out.Namespace = *o.Namespace + } + if o.PrismaRRN != nil { + out.PrismaRRN = *o.PrismaRRN + } + if o.PrismaRegion != nil { + out.PrismaRegion = *o.PrismaRegion + } + if o.ResourceID != nil { + out.ResourceID = *o.ResourceID + } + if o.UpdateTime != nil { + out.UpdateTime = *o.UpdateTime + } + if o.ZHash != nil { + out.ZHash = *o.ZHash + } + if o.Zone != nil { + out.Zone = *o.Zone + } + + return out +} + +// GetCreateTime returns the CreateTime of the receiver. +func (o *SparseAWSResource) GetCreateTime() (out time.Time) { + + if o.CreateTime == nil { + return + } + + return *o.CreateTime +} + +// SetCreateTime sets the property CreateTime of the receiver using the address of the given value. +func (o *SparseAWSResource) SetCreateTime(createTime time.Time) { + + o.CreateTime = &createTime +} + +// GetMigrationsLog returns the MigrationsLog of the receiver. +func (o *SparseAWSResource) GetMigrationsLog() (out map[string]string) { + + if o.MigrationsLog == nil { + return + } + + return *o.MigrationsLog +} + +// SetMigrationsLog sets the property MigrationsLog of the receiver using the address of the given value. +func (o *SparseAWSResource) SetMigrationsLog(migrationsLog map[string]string) { + + o.MigrationsLog = &migrationsLog +} + +// GetNamespace returns the Namespace of the receiver. +func (o *SparseAWSResource) GetNamespace() (out string) { + + if o.Namespace == nil { + return + } + + return *o.Namespace +} + +// SetNamespace sets the property Namespace of the receiver using the address of the given value. +func (o *SparseAWSResource) SetNamespace(namespace string) { + + o.Namespace = &namespace +} + +// GetUpdateTime returns the UpdateTime of the receiver. +func (o *SparseAWSResource) GetUpdateTime() (out time.Time) { + + if o.UpdateTime == nil { + return + } + + return *o.UpdateTime +} + +// SetUpdateTime sets the property UpdateTime of the receiver using the address of the given value. +func (o *SparseAWSResource) SetUpdateTime(updateTime time.Time) { + + o.UpdateTime = &updateTime +} + +// GetZHash returns the ZHash of the receiver. +func (o *SparseAWSResource) GetZHash() (out int) { + + if o.ZHash == nil { + return + } + + return *o.ZHash +} + +// SetZHash sets the property ZHash of the receiver using the address of the given value. +func (o *SparseAWSResource) SetZHash(zHash int) { + + o.ZHash = &zHash +} + +// GetZone returns the Zone of the receiver. +func (o *SparseAWSResource) GetZone() (out int) { + + if o.Zone == nil { + return + } + + return *o.Zone +} + +// SetZone sets the property Zone of the receiver using the address of the given value. +func (o *SparseAWSResource) SetZone(zone int) { + + o.Zone = &zone +} + +// DeepCopy returns a deep copy if the SparseAWSResource. +func (o *SparseAWSResource) DeepCopy() *SparseAWSResource { + + if o == nil { + return nil + } + + out := &SparseAWSResource{} + o.DeepCopyInto(out) + + return out +} + +// DeepCopyInto copies the receiver into the given *SparseAWSResource. +func (o *SparseAWSResource) DeepCopyInto(out *SparseAWSResource) { + + target, err := copystructure.Copy(o) + if err != nil { + panic(fmt.Sprintf("Unable to deepcopy SparseAWSResource: %s", err)) + } + + *out = *target.(*SparseAWSResource) +} + +type mongoAttributesAWSResource struct { + ID bson.ObjectId `bson:"_id,omitempty"` + AccountID string `bson:"accountid,omitempty"` + Arn string `bson:"arn"` + CreateTime time.Time `bson:"createtime"` + Data []byte `bson:"data"` + DenormedFields []string `bson:"denormedfields"` + Kind AWSResourceKindValue `bson:"kind"` + MigrationsLog map[string]string `bson:"migrationslog,omitempty"` + Name string `bson:"name"` + Namespace string `bson:"namespace"` + PrismaRRN string `bson:"prismarrn,omitempty"` + PrismaRegion string `bson:"prismaregion"` + ResourceID string `bson:"resourceid"` + UpdateTime time.Time `bson:"updatetime"` + ZHash int `bson:"zhash"` + Zone int `bson:"zone"` +} +type mongoAttributesSparseAWSResource struct { + ID bson.ObjectId `bson:"_id,omitempty"` + AccountID *string `bson:"accountid,omitempty"` + Arn *string `bson:"arn,omitempty"` + CreateTime *time.Time `bson:"createtime,omitempty"` + Data *[]byte `bson:"data,omitempty"` + DenormedFields *[]string `bson:"denormedfields,omitempty"` + Kind *AWSResourceKindValue `bson:"kind,omitempty"` + MigrationsLog *map[string]string `bson:"migrationslog,omitempty"` + Name *string `bson:"name,omitempty"` + Namespace *string `bson:"namespace,omitempty"` + PrismaRRN *string `bson:"prismarrn,omitempty"` + PrismaRegion *string `bson:"prismaregion,omitempty"` + ResourceID *string `bson:"resourceid,omitempty"` + UpdateTime *time.Time `bson:"updatetime,omitempty"` + ZHash *int `bson:"zhash,omitempty"` + Zone *int `bson:"zone,omitempty"` +} diff --git a/doc/documentation.md b/doc/documentation.md index 637975675..935996ea4 100644 --- a/doc/documentation.md +++ b/doc/documentation.md @@ -9765,6 +9765,118 @@ The associated IP/FQDN risk level. ## pcn/infrastructure +### AWSAsset + +Represents a read-only AWS cloud resource such as a virtual machine. + +#### Example + +```json +{ + "arn": "arn:aws:ec2:us-west-2:000000000000:instance/i-0abcdef0123456789", + "data": "{ + \"instanceId\": \"i-0abcdef0123456789\", + \"placement\": { + \"availabilityZone\": \"us-west-2a\" + }, + ... +}", + "kind": "Instance", + "name": "abc", + "prismaRegion": "us-east-1", + "resourceID": "i-092bf3d4b2422d8a6" +} +``` + +#### Attributes + +##### `ID` [`identifier`,`autogenerated`,`read_only`] + +Type: `string` + +Identifier of the object. + +##### `accountID` [`autogenerated`,`read_only`] + +Type: `string` + +The 12 digit ID of the AWS account the resource belongs. + +##### `arn` [`autogenerated`,`read_only`] + +Type: `string` + +The ARN of the resource in AWS. + +##### `createTime` [`autogenerated`,`read_only`] + +Type: `time` + +Creation date of the object. + +##### `data` [`required`] + +Type: `[]byte` + +The JSON-encoded data that represents the resource. + +##### `denormedFields` [`autogenerated`,`read_only`] + +Type: `[]string` + +Contextual values that can be used to narrow searching of resources if the +arn or resourceID are not known. For instance, it could be used to store +a resource's Subnet or VPC ID. + +##### `kind` [`autogenerated`,`read_only`] + +Type: `enum(Pending | Instance | NetworkInterface | VPC | Subnet | NetworkACL | InternetGateway | SecurityGroup)` + +The specific kind of the resource. + +Default value: + +```json +"Pending" +``` + +##### `name` + +Type: `string` + +The name of the resource. + +##### `namespace` [`autogenerated`,`read_only`] + +Type: `string` + +Namespace tag attached to an entity. + +##### `prismaRRN` + +Type: `string` + +The resource identifier in PrismaCloud. + +##### `prismaRegion` + +Type: `string` + +The region this resource exists in according to PrismaCloud. Note that the +resource may exists in a different region as described by AWS. + +##### `resourceID` [`autogenerated`,`read_only`] + +Type: `string` + +A resource ID that will mainly be used in RQL queries. + +##### `updateTime` [`autogenerated`,`read_only`] + +Type: `time` + +Last update date of the object. + ### AzureAsset Represents a read-only Azure cloud resource such as virtualMachines and subnets. diff --git a/identities_registry.go b/identities_registry.go index 3f6635972..06e180069 100644 --- a/identities_registry.go +++ b/identities_registry.go @@ -26,6 +26,8 @@ var ( "automation": AutomationIdentity, "automationaction": AutomationActionIdentity, "automationcondition": AutomationConditionIdentity, + "awsasset": AWSAssetIdentity, + "awsresource": AWSResourceIdentity, "azureasset": AzureAssetIdentity, "azureresource": AzureResourceIdentity, "cachedflowreport": CachedFlowReportIdentity, @@ -243,6 +245,8 @@ var ( "automations": AutomationIdentity, "automationactions": AutomationActionIdentity, "automationconditions": AutomationConditionIdentity, + "awsassets": AWSAssetIdentity, + "awsresources": AWSResourceIdentity, "azureassets": AzureAssetIdentity, "azureresources": AzureResourceIdentity, "cachedflowreports": CachedFlowReportIdentity, @@ -683,6 +687,19 @@ var ( {"propagate"}, {"updateIdempotencyKey"}, }, + "awsasset": { + {":shard", ":unique", "zone", "zHash"}, + {"namespace"}, + {"namespace", "normalizedTags"}, + }, + "awsresource": { + {":shard", ":unique", "zone", "zHash"}, + {"namespace"}, + {"namespace", "arn"}, + {"namespace", "kind"}, + {"namespace", "normalizedTags"}, + {"namespace", "resourceID"}, + }, "azureasset": { {":shard", ":unique", "zone", "zHash"}, {"namespace"}, @@ -1522,6 +1539,10 @@ func (f modelManager) Identifiable(identity elemental.Identity) elemental.Identi return NewAutomationAction() case AutomationConditionIdentity: return NewAutomationCondition() + case AWSAssetIdentity: + return NewAWSAsset() + case AWSResourceIdentity: + return NewAWSResource() case AzureAssetIdentity: return NewAzureAsset() case AzureResourceIdentity: @@ -1893,6 +1914,10 @@ func (f modelManager) SparseIdentifiable(identity elemental.Identity) elemental. return NewSparseAutomationAction() case AutomationConditionIdentity: return NewSparseAutomationCondition() + case AWSAssetIdentity: + return NewSparseAWSAsset() + case AWSResourceIdentity: + return NewSparseAWSResource() case AzureAssetIdentity: return NewSparseAzureAsset() case AzureResourceIdentity: @@ -2272,6 +2297,10 @@ func (f modelManager) Identifiables(identity elemental.Identity) elemental.Ident return &AutomationActionsList{} case AutomationConditionIdentity: return &AutomationConditionsList{} + case AWSAssetIdentity: + return &AWSAssetsList{} + case AWSResourceIdentity: + return &AWSResourcesList{} case AzureAssetIdentity: return &AzureAssetsList{} case AzureResourceIdentity: @@ -2641,6 +2670,10 @@ func (f modelManager) SparseIdentifiables(identity elemental.Identity) elemental return &SparseAutomationActionsList{} case AutomationConditionIdentity: return &SparseAutomationConditionsList{} + case AWSAssetIdentity: + return &SparseAWSAssetsList{} + case AWSResourceIdentity: + return &SparseAWSResourcesList{} case AzureAssetIdentity: return &SparseAzureAssetsList{} case AzureResourceIdentity: @@ -3010,6 +3043,8 @@ func AllIdentities() []elemental.Identity { AutomationIdentity, AutomationActionIdentity, AutomationConditionIdentity, + AWSAssetIdentity, + AWSResourceIdentity, AzureAssetIdentity, AzureResourceIdentity, CachedFlowReportIdentity, @@ -3239,6 +3274,10 @@ func AliasesForIdentity(identity elemental.Identity) []string { return []string{ "autocon", } + case AWSAssetIdentity: + return []string{} + case AWSResourceIdentity: + return []string{} case AzureAssetIdentity: return []string{} case AzureResourceIdentity: diff --git a/openapi3_autogen/awsasset.json b/openapi3_autogen/awsasset.json new file mode 100644 index 000000000..0973b5bf9 --- /dev/null +++ b/openapi3_autogen/awsasset.json @@ -0,0 +1,122 @@ +{ + "components": { + "schemas": { + "awsasset": { + "description": "Represents a read-only AWS cloud resource such as a virtual machine.", + "properties": { + "ID": { + "description": "Identifier of the object.", + "readOnly": true, + "type": "string" + }, + "accountID": { + "description": "The 12 digit ID of the AWS account the resource belongs.", + "readOnly": true, + "type": "string" + }, + "arn": { + "description": "The ARN of the resource in AWS.", + "example": "arn:aws:ec2:us-west-2:000000000000:instance/i-0abcdef0123456789", + "readOnly": true, + "type": "string" + }, + "createTime": { + "description": "Creation date of the object.", + "format": "date-time", + "readOnly": true, + "type": "string" + }, + "data": { + "description": "The JSON-encoded data that represents the resource.", + "example": "{\n \"instanceId\": \"i-0abcdef0123456789\",\n \"placement\": {\n \"availabilityZone\": \"us-west-2a\"\n },\n ...\n}", + "type": "string" + }, + "denormedFields": { + "description": "Contextual values that can be used to narrow searching of resources if the\narn or resourceID are not known. For instance, it could be used to store\na resource's Subnet or VPC ID.", + "items": { + "type": "string" + }, + "readOnly": true, + "type": "array" + }, + "kind": { + "default": "Pending", + "description": "The specific kind of the resource.", + "enum": [ + "Pending", + "Instance", + "NetworkInterface", + "VPC", + "Subnet", + "NetworkACL", + "InternetGateway", + "SecurityGroup" + ], + "example": "Instance", + "readOnly": true + }, + "name": { + "description": "The name of the resource.", + "example": "abc", + "type": "string" + }, + "namespace": { + "description": "Namespace tag attached to an entity.", + "readOnly": true, + "type": "string" + }, + "prismaRRN": { + "description": "The resource identifier in PrismaCloud.", + "type": "string" + }, + "prismaRegion": { + "description": "The region this resource exists in according to PrismaCloud. Note that the\nresource may exists in a different region as described by AWS.", + "example": "us-east-1", + "type": "string" + }, + "resourceID": { + "description": "A resource ID that will mainly be used in RQL queries.", + "example": "i-092bf3d4b2422d8a6", + "readOnly": true, + "type": "string" + }, + "updateTime": { + "description": "Last update date of the object.", + "format": "date-time", + "readOnly": true, + "type": "string" + } + }, + "required": [ + "data" + ], + "type": "object" + } + } + }, + "info": { + "contact": { + "email": "dev@aporeto.com", + "name": "Aporeto Inc.", + "url": "go.aporeto.io/api" + }, + "license": { + "name": "TODO" + }, + "termsOfService": "https://localhost/TODO", + "title": "awsasset", + "version": "1.0" + }, + "openapi": "3.0.3", + "paths": {}, + "tags": [ + { + "description": "This tag is for group 'pcn/infrastructure'", + "name": "pcn/infrastructure" + }, + { + "description": "This tag is for package 'pandemona'", + "name": "pandemona" + } + ] +} diff --git a/relationships_registry.go b/relationships_registry.go index 92bd074bc..bca30203b 100644 --- a/relationships_registry.go +++ b/relationships_registry.go @@ -73,6 +73,10 @@ func init() { }, } + relationshipsRegistry[AWSAssetIdentity] = &elemental.Relationship{} + + relationshipsRegistry[AWSResourceIdentity] = &elemental.Relationship{} + relationshipsRegistry[AccessReportIdentity] = &elemental.Relationship{ Create: map[string]*elemental.RelationshipInfo{ "root": {}, diff --git a/specs/@awsresourceattrs.abs b/specs/@awsresourceattrs.abs new file mode 100644 index 000000000..0b392e2df --- /dev/null +++ b/specs/@awsresourceattrs.abs @@ -0,0 +1,99 @@ +# Attributes +attributes: + v1: + - name: accountID + description: The 12 digit ID of the AWS account the resource belongs. + type: string + exposed: true + stored: true + read_only: true + autogenerated: true + omit_empty: true + + - name: arn + description: The ARN of the resource in AWS. + type: string + exposed: true + stored: true + read_only: true + autogenerated: true + example_value: arn:aws:ec2:us-west-2:000000000000:instance/i-0abcdef0123456789 + + - name: data + description: The JSON-encoded data that represents the resource. + type: external + exposed: true + subtype: '[]byte' + stored: true + required: true + example_value: |- + { + "instanceId": "i-0abcdef0123456789", + "placement": { + "availabilityZone": "us-west-2a" + }, + ... + } + + - name: denormedFields + description: |- + Contextual values that can be used to narrow searching of resources if the + arn or resourceID are not known. For instance, it could be used to store + a resource's Subnet or VPC ID. + type: list + exposed: true + subtype: string + stored: true + read_only: true + autogenerated: true + + - name: kind + description: The specific kind of the resource. + type: enum + exposed: true + stored: true + read_only: true + allowed_choices: + - Pending + - Instance + - NetworkInterface + - VPC + - Subnet + - NetworkACL + - InternetGateway + - SecurityGroup + autogenerated: true + default_value: Pending + example_value: Instance + + - name: name + description: The name of the resource. + type: string + exposed: true + stored: true + example_value: abc + + - name: prismaRRN + description: The resource identifier in PrismaCloud. + type: string + exposed: true + stored: true + omit_empty: true + + - name: prismaRegion + description: |- + The region this resource exists in according to PrismaCloud. Note that the + resource may exists in a different region as described by AWS. + type: string + exposed: true + stored: true + example_value: us-east-1 + + - name: resourceID + description: A resource ID that will mainly be used in RQL queries. + type: string + exposed: true + stored: true + read_only: true + autogenerated: true + example_value: i-092bf3d4b2422d8a6 diff --git a/specs/awsasset.spec b/specs/awsasset.spec new file mode 100644 index 000000000..eeee42814 --- /dev/null +++ b/specs/awsasset.spec @@ -0,0 +1,15 @@ +# Model +model: + rest_name: awsasset + resource_name: awsassets + entity_name: AWSAsset + package: pandemona + group: pcn/infrastructure + description: Represents a read-only AWS cloud resource such as a virtual machine. + extends: + - '@identifiable-stored' + - '@migratable' + - '@namespaced' + - '@zoned' + - '@timeable' + - '@awsresourceattrs' diff --git a/specs/awsresource.spec b/specs/awsresource.spec new file mode 100644 index 000000000..93e9ac5a1 --- /dev/null +++ b/specs/awsresource.spec @@ -0,0 +1,25 @@ +# Model +model: + rest_name: awsresource + resource_name: awsresources + entity_name: AWSResource + package: pandemona + group: pcn/infrastructure + description: Represents a AWS cloud resource such as a virtual machine. + private: true + extends: + - '@identifiable-stored' + - '@migratable' + - '@namespaced' + - '@zoned' + - '@timeable' + - '@awsresourceattrs' + +# Indexes +indexes: +- - namespace + - arn +- - namespace + - resourceID +- - namespace + - kind