mirror of
https://github.com/openziti/ziti.git
synced 2026-09-23 11:03:46 +00:00
Merge pull request #344 from openziti/add.posture.check.api.logic
adds Edge API posture check logic
This commit is contained in:
@@ -114,6 +114,11 @@ func (r *IdentityRouter) Register(ae *env.AppEnv) {
|
||||
ae.Api.IdentityGetIdentityPolicyAdviceHandler = identity.GetIdentityPolicyAdviceHandlerFunc(func(params identity.GetIdentityPolicyAdviceParams, _ interface{}) middleware.Responder {
|
||||
return ae.IsAllowed(r.getPolicyAdvice, params.HTTPRequest, params.ID, params.ServiceID, permissions.IsAdmin())
|
||||
})
|
||||
|
||||
// posture data
|
||||
ae.Api.IdentityGetIdentityPostureDataHandler = identity.GetIdentityPostureDataHandlerFunc(func(params identity.GetIdentityPostureDataParams, _ interface{}) middleware.Responder {
|
||||
return ae.IsAllowed(r.getPostureData, params.HTTPRequest, params.ID, "", permissions.IsAdmin())
|
||||
})
|
||||
}
|
||||
|
||||
func (r *IdentityRouter) List(ae *env.AppEnv, rc *response.RequestContext) {
|
||||
@@ -278,3 +283,26 @@ func (r *IdentityRouter) getPolicyAdvice(ae *env.AppEnv, rc *response.RequestCon
|
||||
output := MapAdvisorServiceReachabilityToRestEntity(result)
|
||||
rc.RespondWithOk(output, nil)
|
||||
}
|
||||
|
||||
func (r *IdentityRouter) getPostureData(_ *env.AppEnv, rc *response.RequestContext) {
|
||||
rc.RespondWithOk(map[string]interface{}{
|
||||
"os": struct {
|
||||
Type string
|
||||
Version string
|
||||
}{
|
||||
"Linux",
|
||||
"4.19",
|
||||
},
|
||||
"domain": struct {
|
||||
Name string
|
||||
}{
|
||||
"",
|
||||
},
|
||||
"mac": struct {
|
||||
Addresses []string
|
||||
}{
|
||||
[]string{"39979133921d", "e031ca6cd289"},
|
||||
},
|
||||
"processes": []interface{}{},
|
||||
}, nil)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package routes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/edge/controller/env"
|
||||
"github.com/openziti/edge/controller/model"
|
||||
@@ -25,6 +26,7 @@ import (
|
||||
"github.com/openziti/edge/rest_model"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/util/stringz"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const EntityNamePostureCheck = "posture-checks"
|
||||
@@ -51,7 +53,42 @@ func MapCreatePostureCheckToModel(postureCheck rest_model.PostureCheckCreate) *m
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: postureCheck.Tags(),
|
||||
},
|
||||
Name: stringz.OrEmpty(postureCheck.Name()),
|
||||
Name: stringz.OrEmpty(postureCheck.Name()),
|
||||
TypeId: string(postureCheck.TypeID()),
|
||||
Description: stringz.OrEmpty(postureCheck.Description()),
|
||||
Version: 1,
|
||||
RoleAttributes: postureCheck.RoleAttributes(),
|
||||
}
|
||||
|
||||
switch apiSubType := postureCheck.(type) {
|
||||
case *rest_model.PostureCheckOperatingSystemCreate:
|
||||
subType := &model.PostureCheckOperatingSystem{
|
||||
OperatingSystems: []model.OperatingSystem{},
|
||||
}
|
||||
|
||||
for _, os := range apiSubType.OperatingSystems {
|
||||
subType.OperatingSystems = append(subType.OperatingSystems, model.OperatingSystem{
|
||||
OsType: string(os.Type),
|
||||
OsVersions: os.Versions,
|
||||
})
|
||||
}
|
||||
ret.SubType = subType
|
||||
|
||||
case *rest_model.PostureCheckDomainCreate:
|
||||
ret.SubType = &model.PostureCheckWindowsDomains{
|
||||
Domains: apiSubType.Domains,
|
||||
}
|
||||
case *rest_model.PostureCheckMacAddressCreate:
|
||||
ret.SubType = &model.PostureCheckMacAddresses{
|
||||
MacAddresses: apiSubType.MacAddresses,
|
||||
}
|
||||
case *rest_model.PostureCheckProcessCreate:
|
||||
ret.SubType = &model.PostureCheckProcess{
|
||||
OperatingSystem: string(apiSubType.Process.OsType),
|
||||
Path: *apiSubType.Process.Path,
|
||||
Hashes: apiSubType.Process.Hashes,
|
||||
Fingerprint: apiSubType.Process.SignerFingerprint,
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -63,7 +100,8 @@ func MapUpdatePostureCheckToModel(id string, postureCheck rest_model.PostureChec
|
||||
Tags: postureCheck.Tags(),
|
||||
Id: id,
|
||||
},
|
||||
Name: stringz.OrEmpty(postureCheck.Name()),
|
||||
Name: stringz.OrEmpty(postureCheck.Name()),
|
||||
RoleAttributes: postureCheck.RoleAttributes(),
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -75,7 +113,8 @@ func MapPatchPostureCheckToModel(id string, postureCheck rest_model.PostureCheck
|
||||
Tags: postureCheck.Tags(),
|
||||
Id: id,
|
||||
},
|
||||
Name: postureCheck.Name(),
|
||||
Name: postureCheck.Name(),
|
||||
RoleAttributes: postureCheck.RoleAttributes(),
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -103,5 +142,89 @@ func MapPostureCheckToRestEntity(_ *env.AppEnv, _ *response.RequestContext, e mo
|
||||
}
|
||||
|
||||
func MapPostureCheckToRestModel(i *model.PostureCheck) (rest_model.PostureCheckDetail, error) {
|
||||
return nil, nil
|
||||
var ret rest_model.PostureCheckDetail
|
||||
|
||||
switch subType := i.SubType.(type) {
|
||||
case *model.PostureCheckOperatingSystem:
|
||||
osArray := rest_model.OperatingSystemArray{}
|
||||
|
||||
for _, osMatch := range subType.OperatingSystems {
|
||||
osArray = append(osArray, &rest_model.OperatingSystem{
|
||||
Type: rest_model.OsType(osMatch.OsType),
|
||||
Versions: osMatch.OsVersions,
|
||||
})
|
||||
}
|
||||
|
||||
ret = &rest_model.PostureCheckOperatingSystemDetail{
|
||||
OperatingSystems: osArray,
|
||||
}
|
||||
|
||||
setBaseEntityDetailsOnPostureCheck(ret, i)
|
||||
|
||||
case *model.PostureCheckProcess:
|
||||
processMatch := &rest_model.Process{
|
||||
Hashes: subType.Hashes,
|
||||
OsType: rest_model.OsType(subType.OperatingSystem),
|
||||
Path: &subType.Path,
|
||||
SignerFingerprint: subType.Fingerprint,
|
||||
}
|
||||
|
||||
ret = &rest_model.PostureCheckProcessDetail{
|
||||
Process: processMatch,
|
||||
}
|
||||
|
||||
setBaseEntityDetailsOnPostureCheck(ret, i)
|
||||
case *model.PostureCheckWindowsDomains:
|
||||
ret = &rest_model.PostureCheckDomainDetail{
|
||||
Domains: subType.Domains,
|
||||
}
|
||||
setBaseEntityDetailsOnPostureCheck(ret, i)
|
||||
case *model.PostureCheckMacAddresses:
|
||||
ret = &rest_model.PostureCheckMacAddressDetail{
|
||||
MacAddresses: subType.MacAddresses,
|
||||
}
|
||||
setBaseEntityDetailsOnPostureCheck(ret, i)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func setBaseEntityDetailsOnPostureCheck(check rest_model.PostureCheckDetail, i *model.PostureCheck) {
|
||||
createdAt := strfmt.DateTime(i.CreatedAt)
|
||||
updatedAt := strfmt.DateTime(i.UpdatedAt)
|
||||
check.SetCreatedAt(&createdAt)
|
||||
check.SetUpdatedAt(&updatedAt)
|
||||
check.SetTags(i.Tags)
|
||||
check.SetID(&i.Id)
|
||||
check.SetLinks(PostureCheckLinkFactory.Links(i))
|
||||
check.SetDescription(&i.Description)
|
||||
check.SetName(&i.Name)
|
||||
check.SetTypeID(i.TypeId)
|
||||
check.SetVersion(&i.Version)
|
||||
check.SetRoleAttributes(i.RoleAttributes)
|
||||
}
|
||||
|
||||
func GetNamedPostureCheckRoles(postureCheckHandler *model.PostureCheckHandler, roles []string) rest_model.NamedRoles {
|
||||
result := rest_model.NamedRoles{}
|
||||
for _, role := range roles {
|
||||
if strings.HasPrefix(role, "@") {
|
||||
|
||||
postureCheck, err := postureCheckHandler.Read(role[1:])
|
||||
if err != nil {
|
||||
pfxlog.Logger().Errorf("error converting posture check role [%s] to a named role: %v", role, err)
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result, &rest_model.NamedRole{
|
||||
Role: role,
|
||||
Name: "@" + postureCheck.Name,
|
||||
})
|
||||
} else {
|
||||
result = append(result, &rest_model.NamedRole{
|
||||
Role: role,
|
||||
Name: role,
|
||||
})
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/edge/controller/env"
|
||||
"github.com/openziti/edge/controller/model"
|
||||
"github.com/openziti/edge/controller/response"
|
||||
"github.com/openziti/edge/rest_model"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
)
|
||||
|
||||
const EntityNamePostureCheckType = "posture-check-types"
|
||||
|
||||
var PostureCheckTypeLinkFactory = NewBasicLinkFactory(EntityNamePostureCheckType)
|
||||
|
||||
func MapPostureCheckTypeToRestEntity(_ *env.AppEnv, _ *response.RequestContext, postureCheckTypeModel models.Entity) (interface{}, error) {
|
||||
postureCheckType, ok := postureCheckTypeModel.(*model.PostureCheckType)
|
||||
|
||||
if !ok {
|
||||
err := fmt.Errorf("entity is not a posture check type \"%s\"", postureCheckTypeModel.GetId())
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
restModel := MapPostureCheckTypeToRestModel(postureCheckType)
|
||||
|
||||
return restModel, nil
|
||||
}
|
||||
|
||||
func MapPostureCheckTypeToRestModel(postureCheckType *model.PostureCheckType) *rest_model.PostureCheckTypeDetail {
|
||||
|
||||
operatingSystems := rest_model.OperatingSystemArray{}
|
||||
|
||||
for _, os := range postureCheckType.OperatingSystems {
|
||||
|
||||
newOs := &rest_model.OperatingSystem{
|
||||
Type: rest_model.OsType(os.OsType),
|
||||
Versions: os.OsVersions,
|
||||
}
|
||||
operatingSystems = append(operatingSystems, newOs)
|
||||
}
|
||||
|
||||
ret := &rest_model.PostureCheckTypeDetail{
|
||||
BaseEntity: BaseEntityToRestModel(postureCheckType, PostureCheckTypeLinkFactory),
|
||||
Name: &postureCheckType.Name,
|
||||
OperatingSystems: operatingSystems,
|
||||
}
|
||||
return ret
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/edge/controller/env"
|
||||
"github.com/openziti/edge/controller/internal/permissions"
|
||||
"github.com/openziti/edge/controller/response"
|
||||
"github.com/openziti/edge/rest_server/operations/posture_checks"
|
||||
)
|
||||
|
||||
func init() {
|
||||
r := NewPostureCheckTypeRouter()
|
||||
env.AddRouter(r)
|
||||
}
|
||||
|
||||
type PostureCheckTypeRouter struct {
|
||||
BasePath string
|
||||
}
|
||||
|
||||
func NewPostureCheckTypeRouter() *PostureCheckTypeRouter {
|
||||
return &PostureCheckTypeRouter{
|
||||
BasePath: "/" + EntityNamePostureCheckType,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *PostureCheckTypeRouter) Register(ae *env.AppEnv) {
|
||||
|
||||
ae.Api.PostureChecksDetailPostureCheckTypeHandler = posture_checks.DetailPostureCheckTypeHandlerFunc(func(params posture_checks.DetailPostureCheckTypeParams, _ interface{}) middleware.Responder {
|
||||
return ae.IsAllowed(r.Detail, params.HTTPRequest, params.ID, "", permissions.IsAdmin())
|
||||
})
|
||||
|
||||
ae.Api.PostureChecksListPostureCheckTypesHandler = posture_checks.ListPostureCheckTypesHandlerFunc(func(params posture_checks.ListPostureCheckTypesParams, _ interface{}) middleware.Responder {
|
||||
return ae.IsAllowed(r.List, params.HTTPRequest, "", "", permissions.IsAdmin())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (r *PostureCheckTypeRouter) List(ae *env.AppEnv, rc *response.RequestContext) {
|
||||
ListWithHandler(ae, rc, ae.Handlers.PostureCheckType, MapPostureCheckTypeToRestEntity)
|
||||
}
|
||||
|
||||
func (r *PostureCheckTypeRouter) Detail(ae *env.AppEnv, rc *response.RequestContext) {
|
||||
DetailWithHandler(ae, rc, ae.Handlers.PostureCheckType, MapPostureCheckTypeToRestEntity)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func MapCreateServiceToModel(service *rest_model.ServiceCreate) *model.Service {
|
||||
TerminatorStrategy: service.TerminatorStrategy,
|
||||
RoleAttributes: service.RoleAttributes,
|
||||
Configs: service.Configs,
|
||||
EncryptionRequired: service.EncryptionRequired,
|
||||
EncryptionRequired: *service.EncryptionRequired,
|
||||
}
|
||||
|
||||
return ret
|
||||
|
||||
@@ -54,11 +54,12 @@ func MapCreateServicePolicyToModel(policy *rest_model.ServicePolicyCreate) *mode
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: policy.Tags,
|
||||
},
|
||||
Name: stringz.OrEmpty(policy.Name),
|
||||
PolicyType: string(policy.Type),
|
||||
Semantic: string(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
Name: stringz.OrEmpty(policy.Name),
|
||||
PolicyType: string(policy.Type),
|
||||
Semantic: string(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
PostureCheckRoles: policy.PostureCheckRoles,
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -70,11 +71,12 @@ func MapUpdateServicePolicyToModel(id string, policy *rest_model.ServicePolicyUp
|
||||
Tags: policy.Tags,
|
||||
Id: id,
|
||||
},
|
||||
Name: stringz.OrEmpty(policy.Name),
|
||||
PolicyType: string(policy.Type),
|
||||
Semantic: string(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
Name: stringz.OrEmpty(policy.Name),
|
||||
PolicyType: string(policy.Type),
|
||||
Semantic: string(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
PostureCheckRoles: policy.PostureCheckRoles,
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -86,11 +88,12 @@ func MapPatchServicePolicyToModel(id string, policy *rest_model.ServicePolicyPat
|
||||
Tags: policy.Tags,
|
||||
Id: id,
|
||||
},
|
||||
Name: policy.Name,
|
||||
PolicyType: string(policy.Type),
|
||||
Semantic: string(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
Name: policy.Name,
|
||||
PolicyType: string(policy.Type),
|
||||
Semantic: string(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
PostureCheckRoles: policy.PostureCheckRoles,
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -119,14 +122,16 @@ func MapServicePolicyToRestEntity(ae *env.AppEnv, _ *response.RequestContext, e
|
||||
|
||||
func MapServicePolicyToRestModel(ae *env.AppEnv, policy *model.ServicePolicy) (*rest_model.ServicePolicyDetail, error) {
|
||||
ret := &rest_model.ServicePolicyDetail{
|
||||
BaseEntity: BaseEntityToRestModel(policy, ServicePolicyLinkFactory),
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
IdentityRolesDisplay: GetNamedIdentityRoles(ae.GetHandlers().Identity, policy.IdentityRoles),
|
||||
Name: &policy.Name,
|
||||
Semantic: rest_model.Semantic(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
ServiceRolesDisplay: GetNamedServiceRoles(ae.GetHandlers().EdgeService, policy.ServiceRoles),
|
||||
Type: rest_model.DialBind(policy.PolicyType),
|
||||
BaseEntity: BaseEntityToRestModel(policy, ServicePolicyLinkFactory),
|
||||
IdentityRoles: policy.IdentityRoles,
|
||||
IdentityRolesDisplay: GetNamedIdentityRoles(ae.GetHandlers().Identity, policy.IdentityRoles),
|
||||
Name: &policy.Name,
|
||||
Semantic: rest_model.Semantic(policy.Semantic),
|
||||
ServiceRoles: policy.ServiceRoles,
|
||||
ServiceRolesDisplay: GetNamedServiceRoles(ae.GetHandlers().EdgeService, policy.ServiceRoles),
|
||||
Type: rest_model.DialBind(policy.PolicyType),
|
||||
PostureCheckRoles: policy.PostureCheckRoles,
|
||||
PostureCheckRolesDisplay: GetNamedPostureCheckRoles(ae.GetHandlers().PostureCheck, policy.PostureCheckRoles),
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
|
||||
@@ -46,6 +46,7 @@ type Handlers struct {
|
||||
Authenticator *AuthenticatorHandler
|
||||
Enrollment *EnrollmentHandler
|
||||
PostureCheck *PostureCheckHandler
|
||||
PostureCheckType *PostureCheckTypeHandler
|
||||
}
|
||||
|
||||
func InitHandlers(env Env) *Handlers {
|
||||
@@ -74,6 +75,7 @@ func InitHandlers(env Env) *Handlers {
|
||||
handlers.Session = NewSessionHandler(env)
|
||||
handlers.TransitRouter = NewTransitRouterHandler(env)
|
||||
handlers.PostureCheck = NewPostureCheckHandler(env)
|
||||
handlers.PostureCheckType = NewPostureCheckTypeHandler(env)
|
||||
|
||||
return handlers
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/edge/controller/persistence"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
@@ -27,38 +28,86 @@ import (
|
||||
|
||||
type PostureCheck struct {
|
||||
models.BaseEntity
|
||||
Name string
|
||||
Name string
|
||||
TypeId string
|
||||
Description string
|
||||
Version int64
|
||||
RoleAttributes []string
|
||||
SubType PostureCheckSubType
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) fillFrom(_ Handler, _ *bbolt.Tx, boltEntity boltz.Entity) error {
|
||||
type PostureCheckSubType interface {
|
||||
toBoltEntityForCreate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error)
|
||||
toBoltEntityForUpdate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error)
|
||||
toBoltEntityForPatch(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error)
|
||||
fillFrom(handler Handler, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error
|
||||
}
|
||||
|
||||
type newPostureCheckSubType func() PostureCheckSubType
|
||||
|
||||
var postureCheckSubTypeMap = map[string]newPostureCheckSubType{
|
||||
"OS": newPostureCheckOperatingSystem,
|
||||
"DOMAIN": newPostureCheckWindowsDomains,
|
||||
"PROCESS": newPostureCheckProcess,
|
||||
"MAC": newPostureCheckMacAddresses,
|
||||
}
|
||||
|
||||
func newSubType(typeId string) PostureCheckSubType {
|
||||
if factory, ok := postureCheckSubTypeMap[typeId]; ok {
|
||||
return factory()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) fillFrom(handler Handler, tx *bbolt.Tx, boltEntity boltz.Entity) error {
|
||||
boltPostureCheck, ok := boltEntity.(*persistence.PostureCheck)
|
||||
if !ok {
|
||||
return errors.Errorf("unexpected type %v when filling model ca", reflect.TypeOf(boltEntity))
|
||||
return errors.Errorf("unexpected type %v when filling model posture check", reflect.TypeOf(boltEntity))
|
||||
}
|
||||
entity.FillCommon(boltPostureCheck)
|
||||
entity.Name = boltPostureCheck.Name
|
||||
entity.TypeId = boltPostureCheck.TypeId
|
||||
entity.Description = boltPostureCheck.Description
|
||||
entity.Version = boltPostureCheck.Version
|
||||
entity.RoleAttributes = boltPostureCheck.RoleAttributes
|
||||
|
||||
subType := newSubType(entity.TypeId)
|
||||
|
||||
if subType == nil {
|
||||
return fmt.Errorf("cannot create posture check subtype [%v]", entity.TypeId)
|
||||
}
|
||||
|
||||
if err := subType.fillFrom(handler, tx, boltPostureCheck, boltPostureCheck.SubType); err != nil {
|
||||
return fmt.Errorf("error filling posture check subType [%v]: %v", entity.TypeId, err)
|
||||
}
|
||||
|
||||
entity.SubType = subType
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) toBoltEntityForCreate(tx *bbolt.Tx, handler Handler) (boltz.Entity, error) {
|
||||
|
||||
boltEntity := &persistence.PostureCheck{
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
TypeId: entity.TypeId,
|
||||
Description: entity.Description,
|
||||
Version: 1,
|
||||
RoleAttributes: entity.RoleAttributes,
|
||||
}
|
||||
|
||||
var err error
|
||||
if boltEntity.SubType, err = entity.SubType.toBoltEntityForCreate(tx, handler); err != nil {
|
||||
return nil, fmt.Errorf("error converting to bolt posture check subType [%v] for create: %v", entity.TypeId, err)
|
||||
}
|
||||
|
||||
return boltEntity, nil
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) toBoltEntityForUpdate(_ *bbolt.Tx, _ Handler) (boltz.Entity, error) {
|
||||
boltEntity := &persistence.PostureCheck{
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
}
|
||||
|
||||
return boltEntity, nil
|
||||
func (entity *PostureCheck) toBoltEntityForUpdate(tx *bbolt.Tx, handler Handler) (boltz.Entity, error) {
|
||||
return entity.toBoltEntityForCreate(tx, handler)
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) toBoltEntityForPatch(tx *bbolt.Tx, handler Handler) (boltz.Entity, error) {
|
||||
return entity.toBoltEntityForUpdate(tx, handler)
|
||||
return entity.toBoltEntityForCreate(tx, handler)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/edge/controller/persistence"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
type PostureCheckMacAddresses struct {
|
||||
MacAddresses []string
|
||||
}
|
||||
|
||||
func newPostureCheckMacAddresses() PostureCheckSubType {
|
||||
return &PostureCheckMacAddresses{}
|
||||
}
|
||||
|
||||
func (p *PostureCheckMacAddresses) fillFrom(handler Handler, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error {
|
||||
subCheck := subType.(*persistence.PostureCheckMacAddresses)
|
||||
|
||||
if subCheck == nil {
|
||||
return fmt.Errorf("could not covert mac address check to bolt type")
|
||||
}
|
||||
|
||||
p.MacAddresses = subCheck.MacAddresses
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckMacAddresses) toBoltEntityForCreate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckMacAddresses{
|
||||
MacAddresses: p.MacAddresses,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckMacAddresses) toBoltEntityForUpdate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckMacAddresses{
|
||||
MacAddresses: p.MacAddresses,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckMacAddresses) toBoltEntityForPatch(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckMacAddresses{
|
||||
MacAddresses: p.MacAddresses,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/edge/controller/persistence"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
type PostureCheckOperatingSystem struct {
|
||||
OperatingSystems []OperatingSystem
|
||||
}
|
||||
|
||||
type OperatingSystem struct {
|
||||
OsType string
|
||||
OsVersions []string
|
||||
}
|
||||
|
||||
func newPostureCheckOperatingSystem() PostureCheckSubType {
|
||||
return &PostureCheckOperatingSystem{}
|
||||
}
|
||||
|
||||
func (p *PostureCheckOperatingSystem) fillFrom(handler Handler, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error {
|
||||
subCheck := subType.(*persistence.PostureCheckOperatingSystem)
|
||||
|
||||
if subCheck == nil {
|
||||
return fmt.Errorf("could not covert os check to bolt type")
|
||||
}
|
||||
|
||||
for _, osMatch := range subCheck.OperatingSystems {
|
||||
p.OperatingSystems = append(p.OperatingSystems, OperatingSystem{
|
||||
OsType: osMatch.OsType,
|
||||
OsVersions: osMatch.OsVersions,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckOperatingSystem) toBoltEntityForCreate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
ret := &persistence.PostureCheckOperatingSystem{
|
||||
OperatingSystems: []persistence.OperatingSystem{},
|
||||
}
|
||||
|
||||
for _, osMatch := range p.OperatingSystems {
|
||||
ret.OperatingSystems = append(ret.OperatingSystems, persistence.OperatingSystem{
|
||||
OsType: osMatch.OsType,
|
||||
OsVersions: osMatch.OsVersions,
|
||||
})
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckOperatingSystem) toBoltEntityForUpdate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
ret := &persistence.PostureCheckOperatingSystem{
|
||||
OperatingSystems: []persistence.OperatingSystem{},
|
||||
}
|
||||
|
||||
for _, osMatch := range p.OperatingSystems {
|
||||
ret.OperatingSystems = append(ret.OperatingSystems, persistence.OperatingSystem{
|
||||
OsType: osMatch.OsType,
|
||||
OsVersions: osMatch.OsVersions,
|
||||
})
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckOperatingSystem) toBoltEntityForPatch(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
ret := &persistence.PostureCheckOperatingSystem{
|
||||
OperatingSystems: []persistence.OperatingSystem{},
|
||||
}
|
||||
|
||||
for _, osMatch := range p.OperatingSystems {
|
||||
ret.OperatingSystems = append(ret.OperatingSystems, persistence.OperatingSystem{
|
||||
OsType: osMatch.OsType,
|
||||
OsVersions: osMatch.OsVersions,
|
||||
})
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/edge/controller/persistence"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
type PostureCheckProcess struct {
|
||||
OperatingSystem string
|
||||
Path string
|
||||
Hashes []string
|
||||
Fingerprint string
|
||||
}
|
||||
|
||||
func newPostureCheckProcess() PostureCheckSubType {
|
||||
return &PostureCheckProcess{}
|
||||
}
|
||||
|
||||
func (p *PostureCheckProcess) fillFrom(handler Handler, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error {
|
||||
subCheck := subType.(*persistence.PostureCheckProcess)
|
||||
|
||||
if subCheck == nil {
|
||||
return fmt.Errorf("could not covert process check to bolt type")
|
||||
}
|
||||
|
||||
p.OperatingSystem = subCheck.OperatingSystem
|
||||
p.Path = subCheck.Path
|
||||
p.Hashes = subCheck.Hashes
|
||||
p.Fingerprint = subCheck.Fingerprint
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckProcess) toBoltEntityForCreate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckProcess{
|
||||
OperatingSystem: p.OperatingSystem,
|
||||
Path: p.Path,
|
||||
Hashes: p.Hashes,
|
||||
Fingerprint: p.Fingerprint,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckProcess) toBoltEntityForUpdate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckProcess{
|
||||
OperatingSystem: p.OperatingSystem,
|
||||
Path: p.Path,
|
||||
Hashes: p.Hashes,
|
||||
Fingerprint: p.Fingerprint,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckProcess) toBoltEntityForPatch(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckProcess{
|
||||
OperatingSystem: p.OperatingSystem,
|
||||
Path: p.Path,
|
||||
Hashes: p.Hashes,
|
||||
Fingerprint: p.Fingerprint,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/edge/controller/persistence"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
type PostureCheckWindowsDomains struct {
|
||||
Domains []string
|
||||
}
|
||||
|
||||
func newPostureCheckWindowsDomains() PostureCheckSubType {
|
||||
return &PostureCheckWindowsDomains{}
|
||||
}
|
||||
|
||||
func (p *PostureCheckWindowsDomains) fillFrom(handler Handler, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error {
|
||||
subCheck := subType.(*persistence.PostureCheckWindowsDomains)
|
||||
|
||||
if subCheck == nil {
|
||||
return fmt.Errorf("could not covert domain check to bolt type")
|
||||
}
|
||||
|
||||
p.Domains = subCheck.Domains
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckWindowsDomains) toBoltEntityForCreate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckWindowsDomains{
|
||||
Domains: p.Domains,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckWindowsDomains) toBoltEntityForUpdate(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckWindowsDomains{
|
||||
Domains: p.Domains,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PostureCheckWindowsDomains) toBoltEntityForPatch(tx *bbolt.Tx, handler Handler) (persistence.PostureCheckSubType, error) {
|
||||
return &persistence.PostureCheckWindowsDomains{
|
||||
Domains: p.Domains,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
func NewPostureCheckTypeHandler(env Env) *PostureCheckTypeHandler {
|
||||
handler := &PostureCheckTypeHandler{
|
||||
baseHandler: newBaseHandler(env, env.GetStores().PostureCheckType),
|
||||
}
|
||||
handler.impl = handler
|
||||
return handler
|
||||
}
|
||||
|
||||
type PostureCheckTypeHandler struct {
|
||||
baseHandler
|
||||
}
|
||||
|
||||
func (handler *PostureCheckTypeHandler) newModelEntity() boltEntitySink {
|
||||
return &PostureCheckType{}
|
||||
}
|
||||
|
||||
func (handler *PostureCheckTypeHandler) Create(PostureCheckTypeModel *PostureCheckType) (string, error) {
|
||||
return handler.createEntity(PostureCheckTypeModel)
|
||||
}
|
||||
|
||||
func (handler *PostureCheckTypeHandler) Read(id string) (*PostureCheckType, error) {
|
||||
modelEntity := &PostureCheckType{}
|
||||
if err := handler.readEntity(id, modelEntity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return modelEntity, nil
|
||||
}
|
||||
|
||||
func (handler *PostureCheckTypeHandler) Delete(id string) error {
|
||||
return handler.deleteEntity(id)
|
||||
}
|
||||
|
||||
func (handler *PostureCheckTypeHandler) ReadByName(name string) (*PostureCheckType, error) {
|
||||
modelPostureCheckType := &PostureCheckType{}
|
||||
nameIndex := handler.env.GetStores().PostureCheckType.GetNameIndex()
|
||||
if err := handler.readEntityWithIndex("name", []byte(name), nameIndex, modelPostureCheckType); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return modelPostureCheckType, nil
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/openziti/edge/controller/persistence"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/pkg/errors"
|
||||
"go.etcd.io/bbolt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type PostureCheckType struct {
|
||||
models.BaseEntity
|
||||
Name string
|
||||
OperatingSystems []OperatingSystem
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) toBoltEntity() (boltz.Entity, error) {
|
||||
var operatingSystems []persistence.OperatingSystem
|
||||
|
||||
for _, os := range entity.OperatingSystems {
|
||||
operatingSystems = append(operatingSystems, persistence.OperatingSystem{
|
||||
OsType: os.OsType,
|
||||
OsVersions: os.OsVersions,
|
||||
})
|
||||
}
|
||||
|
||||
return &persistence.PostureCheckType{
|
||||
Name: entity.Name,
|
||||
OperatingSystems: operatingSystems,
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) toBoltEntityForCreate(*bbolt.Tx, Handler) (boltz.Entity, error) {
|
||||
return entity.toBoltEntity()
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) toBoltEntityForUpdate(*bbolt.Tx, Handler) (boltz.Entity, error) {
|
||||
return entity.toBoltEntity()
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) toBoltEntityForPatch(*bbolt.Tx, Handler) (boltz.Entity, error) {
|
||||
return entity.toBoltEntity()
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) fillFrom(_ Handler, _ *bbolt.Tx, boltEntity boltz.Entity) error {
|
||||
boltPostureCheckType, ok := boltEntity.(*persistence.PostureCheckType)
|
||||
if !ok {
|
||||
return errors.Errorf("unexpected type %v when filling model PostureCheckType", reflect.TypeOf(boltEntity))
|
||||
}
|
||||
|
||||
var operatingSystems []OperatingSystem
|
||||
|
||||
for _, os := range boltPostureCheckType.OperatingSystems {
|
||||
operatingSystems = append(operatingSystems, OperatingSystem{
|
||||
OsType: os.OsType,
|
||||
OsVersions: os.OsVersions,
|
||||
})
|
||||
}
|
||||
|
||||
entity.FillCommon(boltPostureCheckType)
|
||||
entity.Name = boltPostureCheckType.Name
|
||||
entity.OperatingSystems = operatingSystems
|
||||
return nil
|
||||
}
|
||||
@@ -30,11 +30,12 @@ import (
|
||||
|
||||
type ServicePolicy struct {
|
||||
models.BaseEntity
|
||||
Name string
|
||||
PolicyType string
|
||||
Semantic string
|
||||
IdentityRoles []string
|
||||
ServiceRoles []string
|
||||
Name string
|
||||
PolicyType string
|
||||
Semantic string
|
||||
IdentityRoles []string
|
||||
ServiceRoles []string
|
||||
PostureCheckRoles []string
|
||||
}
|
||||
|
||||
func (entity *ServicePolicy) validatePolicyType() error {
|
||||
@@ -54,12 +55,13 @@ func (entity *ServicePolicy) toBoltEntity() (boltz.Entity, error) {
|
||||
}
|
||||
|
||||
return &persistence.ServicePolicy{
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
PolicyType: policyType,
|
||||
Semantic: entity.Semantic,
|
||||
IdentityRoles: entity.IdentityRoles,
|
||||
ServiceRoles: entity.ServiceRoles,
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
PolicyType: policyType,
|
||||
Semantic: entity.Semantic,
|
||||
IdentityRoles: entity.IdentityRoles,
|
||||
ServiceRoles: entity.ServiceRoles,
|
||||
PostureCheckRoles: entity.PostureCheckRoles,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -94,5 +96,6 @@ func (entity *ServicePolicy) fillFrom(_ Handler, _ *bbolt.Tx, boltEntity boltz.E
|
||||
entity.Semantic = boltServicePolicy.Semantic
|
||||
entity.ServiceRoles = boltServicePolicy.ServiceRoles
|
||||
entity.IdentityRoles = boltServicePolicy.IdentityRoles
|
||||
entity.PostureCheckRoles = boltServicePolicy.PostureCheckRoles
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -38,15 +38,17 @@ const (
|
||||
EntityTypeEnrollments = "enrollments"
|
||||
EntityTypeAuthenticators = "authenticators"
|
||||
EntityTypePostureChecks = "postureChecks"
|
||||
EntityTypePostureCheckTypes = "postureCheckTypes"
|
||||
EdgeBucket = "edge"
|
||||
|
||||
FieldName = "name"
|
||||
FieldSemantic = "semantic"
|
||||
FieldRoleAttributes = "roleAttributes"
|
||||
|
||||
FieldEdgeRouterRoles = "edgeRouterRoles"
|
||||
FieldIdentityRoles = "identityRoles"
|
||||
FieldServiceRoles = "serviceRoles"
|
||||
FieldEdgeRouterRoles = "edgeRouterRoles"
|
||||
FieldIdentityRoles = "identityRoles"
|
||||
FieldServiceRoles = "serviceRoles"
|
||||
FieldPostureCheckRoles = "postureCheckRoles"
|
||||
|
||||
SemanticAllOf = "AllOf"
|
||||
SemanticAnyOf = "AnyOf"
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (m *Migrations) addPostureCheckTypes(step *boltz.MigrationStep) {
|
||||
windows := OperatingSystem{
|
||||
OsType: "Windows",
|
||||
OsVersions: []string{"Vista", "7", "8", "10", "2000"},
|
||||
}
|
||||
|
||||
linux := OperatingSystem{
|
||||
OsType: "Linux",
|
||||
OsVersions: []string{"4.14", "4.19", "5.4", "5.9"},
|
||||
}
|
||||
|
||||
iOS := OperatingSystem{
|
||||
OsType: "iOS",
|
||||
OsVersions: []string{"11", "12"},
|
||||
}
|
||||
|
||||
macOS := OperatingSystem{
|
||||
OsType: "macOS",
|
||||
OsVersions: []string{"10.15", "11.0"},
|
||||
}
|
||||
|
||||
android := OperatingSystem{
|
||||
OsType: "Android",
|
||||
OsVersions: []string{"9", "10", "11"},
|
||||
}
|
||||
|
||||
allOS := []OperatingSystem{
|
||||
windows,
|
||||
linux,
|
||||
android,
|
||||
macOS,
|
||||
iOS,
|
||||
}
|
||||
|
||||
types := []*PostureCheckType{
|
||||
{
|
||||
BaseExtEntity: boltz.BaseExtEntity{
|
||||
Id: "OS",
|
||||
ExtEntityFields: boltz.ExtEntityFields{
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
Tags: map[string]interface{}{},
|
||||
Migrate: false,
|
||||
},
|
||||
},
|
||||
Name: "Operating System Check",
|
||||
OperatingSystems: allOS,
|
||||
},
|
||||
{
|
||||
BaseExtEntity: boltz.BaseExtEntity{
|
||||
Id: "PROCESS",
|
||||
ExtEntityFields: boltz.ExtEntityFields{
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
Tags: map[string]interface{}{},
|
||||
Migrate: false,
|
||||
},
|
||||
},
|
||||
Name: "Process Check",
|
||||
OperatingSystems: []OperatingSystem{
|
||||
windows,
|
||||
macOS,
|
||||
linux,
|
||||
},
|
||||
},
|
||||
{
|
||||
BaseExtEntity: boltz.BaseExtEntity{
|
||||
Id: "DOMAIN",
|
||||
ExtEntityFields: boltz.ExtEntityFields{
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
Tags: map[string]interface{}{},
|
||||
Migrate: false,
|
||||
},
|
||||
},
|
||||
Name: "Windows Domain Check",
|
||||
OperatingSystems: []OperatingSystem{
|
||||
windows,
|
||||
},
|
||||
},
|
||||
{
|
||||
BaseExtEntity: boltz.BaseExtEntity{
|
||||
Id: "MAC",
|
||||
ExtEntityFields: boltz.ExtEntityFields{
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
Tags: map[string]interface{}{},
|
||||
Migrate: false,
|
||||
},
|
||||
},
|
||||
Name: "MAC Address Check",
|
||||
OperatingSystems: []OperatingSystem{
|
||||
windows,
|
||||
linux,
|
||||
macOS,
|
||||
android,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, postureCheckType := range types {
|
||||
if err := m.stores.PostureCheckType.Create(step.Ctx, postureCheckType); err != nil {
|
||||
step.SetError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
CurrentDbVersion = 11
|
||||
CurrentDbVersion = 12
|
||||
FieldVersion = "version"
|
||||
)
|
||||
|
||||
@@ -102,6 +102,10 @@ func (m *Migrations) migrate(step *boltz.MigrationStep) int {
|
||||
}))
|
||||
}
|
||||
|
||||
if step.CurrentVersion < 12 {
|
||||
m.addPostureCheckTypes(step)
|
||||
}
|
||||
|
||||
// current version
|
||||
if step.CurrentVersion <= CurrentDbVersion {
|
||||
return CurrentDbVersion
|
||||
|
||||
@@ -17,44 +17,90 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/storage/ast"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
const (
|
||||
//Fields
|
||||
FieldPostureCheckDescription = "description"
|
||||
FieldPostureCheckTypeId = "typeId"
|
||||
FieldPostureCheckVersion = "version"
|
||||
FieldPostureCheckDescription = "description"
|
||||
)
|
||||
|
||||
var postureCheckSubTypeMap = map[string]newPostureCheckSubType{
|
||||
"OS": newPostureCheckOperatingSystem,
|
||||
"DOMAIN": newPostureCheckWindowsDomain,
|
||||
"PROCESS": newPostureCheckProcess,
|
||||
"MAC": newPostureCheckMacAddresses,
|
||||
}
|
||||
|
||||
type newPostureCheckSubType func() PostureCheckSubType
|
||||
|
||||
type PostureCheckSubType interface {
|
||||
LoadValues(store boltz.CrudStore, bucket *boltz.TypedBucket)
|
||||
SetValues(ctx *boltz.PersistContext, bucket *boltz.TypedBucket)
|
||||
}
|
||||
|
||||
func newPostureCheck(typeId string) PostureCheckSubType {
|
||||
if newChild, found := postureCheckSubTypeMap[typeId]; found {
|
||||
return newChild()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type PostureCheck struct {
|
||||
boltz.BaseExtEntity
|
||||
Name string
|
||||
Fingerprint string
|
||||
CertPem string
|
||||
IsVerified bool
|
||||
VerificationToken string
|
||||
IsAutoPostureCheckEnrollmentEnabled bool
|
||||
IsOttPostureCheckEnrollmentEnabled bool
|
||||
IsAuthEnabled bool
|
||||
IdentityRoles []string
|
||||
IdentityNameFormat string
|
||||
Name string
|
||||
TypeId string
|
||||
Description string
|
||||
Version int64
|
||||
RoleAttributes []string
|
||||
SubType PostureCheckSubType
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) GetName() string {
|
||||
return entity.Name
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) LoadValues(_ boltz.CrudStore, bucket *boltz.TypedBucket) {
|
||||
func (entity *PostureCheck) LoadValues(store boltz.CrudStore, bucket *boltz.TypedBucket) {
|
||||
entity.LoadBaseValues(bucket)
|
||||
entity.Name = bucket.GetStringOrError(FieldName)
|
||||
entity.TypeId = bucket.GetStringOrError(FieldPostureCheckTypeId)
|
||||
entity.Description = bucket.GetStringOrError(FieldPostureCheckDescription)
|
||||
entity.Version = bucket.GetInt64WithDefault(FieldPostureCheckVersion, 0)
|
||||
entity.RoleAttributes = bucket.GetStringList(FieldRoleAttributes)
|
||||
|
||||
entity.SubType = newPostureCheck(entity.TypeId)
|
||||
if entity.SubType == nil {
|
||||
pfxlog.Logger().Panicf("cannot load unsupported posture check type [%v]", entity.TypeId)
|
||||
}
|
||||
|
||||
childBucket := bucket.GetOrCreateBucket(entity.TypeId)
|
||||
|
||||
entity.SubType.LoadValues(store, childBucket)
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) SetValues(ctx *boltz.PersistContext) {
|
||||
entity.SetBaseValues(ctx)
|
||||
ctx.SetString(FieldName, entity.Name)
|
||||
ctx.SetString(FieldPostureCheckTypeId, entity.TypeId)
|
||||
ctx.SetString(FieldPostureCheckDescription, entity.Description)
|
||||
ctx.SetInt64(FieldPostureCheckVersion, entity.Version)
|
||||
ctx.SetStringList(FieldRoleAttributes, entity.RoleAttributes)
|
||||
|
||||
childBucket := ctx.Bucket.GetOrCreateBucket(entity.TypeId)
|
||||
|
||||
entity.SubType.SetValues(ctx, childBucket)
|
||||
|
||||
// index change won't fire if we don't have any roles on create, but we need to evaluate if we match any #all roles
|
||||
store := ctx.Store.(*postureCheckStoreImpl)
|
||||
if ctx.IsCreate && len(entity.RoleAttributes) == 0 {
|
||||
store.rolesChanged(ctx.Bucket.Tx(), []byte(entity.Id), nil, nil, ctx.Bucket)
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *PostureCheck) GetEntityType() string {
|
||||
@@ -66,6 +112,7 @@ type PostureCheckStore interface {
|
||||
LoadOneById(tx *bbolt.Tx, id string) (*PostureCheck, error)
|
||||
LoadOneByName(tx *bbolt.Tx, id string) (*PostureCheck, error)
|
||||
LoadOneByQuery(tx *bbolt.Tx, query string) (*PostureCheck, error)
|
||||
GetRoleAttributesIndex() boltz.SetReadIndex
|
||||
}
|
||||
|
||||
func newPostureCheckStore(stores *stores) *postureCheckStoreImpl {
|
||||
@@ -79,19 +126,39 @@ func newPostureCheckStore(stores *stores) *postureCheckStoreImpl {
|
||||
type postureCheckStoreImpl struct {
|
||||
*baseStore
|
||||
indexName boltz.ReadIndex
|
||||
|
||||
symbolServicePolicies boltz.EntitySymbol
|
||||
symbolRoleAttributes boltz.EntitySetSymbol
|
||||
indexRoleAttributes boltz.SetReadIndex
|
||||
}
|
||||
|
||||
func (store *postureCheckStoreImpl) NewStoreEntity() boltz.Entity {
|
||||
return &PostureCheck{}
|
||||
}
|
||||
|
||||
func (store *postureCheckStoreImpl) GetRoleAttributesIndex() boltz.SetReadIndex {
|
||||
return store.indexRoleAttributes
|
||||
}
|
||||
|
||||
func (store *postureCheckStoreImpl) initializeLocal() {
|
||||
store.AddExtEntitySymbols()
|
||||
store.indexName = store.addUniqueNameField()
|
||||
store.AddSymbol(FieldPostureCheckDescription, ast.NodeTypeString)
|
||||
|
||||
store.symbolRoleAttributes = store.AddSetSymbol(FieldRoleAttributes, ast.NodeTypeString)
|
||||
store.indexRoleAttributes = store.AddSetIndex(store.symbolRoleAttributes)
|
||||
|
||||
store.symbolServicePolicies = store.AddFkSetSymbol(EntityTypeServicePolicies, store.stores.servicePolicy)
|
||||
|
||||
store.indexRoleAttributes.AddListener(store.rolesChanged)
|
||||
}
|
||||
|
||||
func (store *postureCheckStoreImpl) initializeLinked() {
|
||||
store.AddLinkCollection(store.symbolServicePolicies, store.stores.servicePolicy.symbolPostureChecks)
|
||||
}
|
||||
|
||||
func (store *postureCheckStoreImpl) GetNameIndex() boltz.ReadIndex {
|
||||
return store.indexName
|
||||
}
|
||||
|
||||
func (store *postureCheckStoreImpl) LoadOneById(tx *bbolt.Tx, id string) (*PostureCheck, error) {
|
||||
@@ -125,3 +192,14 @@ func (store *postureCheckStoreImpl) DeleteById(ctx boltz.MutateContext, id strin
|
||||
func (store *postureCheckStoreImpl) Update(ctx boltz.MutateContext, entity boltz.Entity, checker boltz.FieldChecker) error {
|
||||
return store.baseStore.Update(ctx, entity, checker)
|
||||
}
|
||||
|
||||
func (store *postureCheckStoreImpl) rolesChanged(tx *bbolt.Tx, rowId []byte, _ []boltz.FieldTypeAndValue, new []boltz.FieldTypeAndValue, holder errorz.ErrorHolder) {
|
||||
ctx := &roleAttributeChangeContext{
|
||||
tx: tx,
|
||||
rolesSymbol: store.stores.servicePolicy.symbolPostureChecks,
|
||||
linkCollection: store.stores.servicePolicy.postureCheckCollection,
|
||||
relatedLinkCollection: store.stores.servicePolicy.serviceCollection,
|
||||
ErrorHolder: holder,
|
||||
}
|
||||
store.updateServicePolicyRelatedRoles(ctx, rowId, new)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
FieldPostureCheckMacAddresses = "macAddresses"
|
||||
)
|
||||
|
||||
func newPostureCheckMacAddresses() PostureCheckSubType {
|
||||
return &PostureCheckMacAddresses{
|
||||
MacAddresses: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
type PostureCheckMacAddresses struct {
|
||||
MacAddresses []string
|
||||
}
|
||||
|
||||
func (entity *PostureCheckMacAddresses) LoadValues(_ boltz.CrudStore, bucket *boltz.TypedBucket) {
|
||||
for _, macAddress := range bucket.GetStringList(FieldPostureCheckMacAddresses) {
|
||||
macAddress = cleanMacAddress(macAddress)
|
||||
entity.MacAddresses = append(entity.MacAddresses, macAddress)
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *PostureCheckMacAddresses) SetValues(ctx *boltz.PersistContext, bucket *boltz.TypedBucket) {
|
||||
var macAddresses []string
|
||||
for _, macAddress := range entity.MacAddresses {
|
||||
macAddress = cleanMacAddress(macAddress)
|
||||
macAddresses = append(macAddresses, macAddress)
|
||||
}
|
||||
entity.MacAddresses = macAddresses
|
||||
bucket.SetStringList(FieldPostureCheckMacAddresses, macAddresses, ctx.FieldChecker)
|
||||
}
|
||||
|
||||
func cleanMacAddress(macAddress string) string {
|
||||
macAddress = strings.ToLower(macAddress)
|
||||
nonHex := regexp.MustCompile("[^a-f0-9]")
|
||||
return nonHex.ReplaceAllString(macAddress, "")
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
)
|
||||
|
||||
const (
|
||||
FieldPostureCheckOsType = "osType"
|
||||
FieldPostureCheckOsVersions = "osVersions"
|
||||
)
|
||||
|
||||
type PostureCheckOperatingSystem struct {
|
||||
OperatingSystems []OperatingSystem
|
||||
}
|
||||
|
||||
type OperatingSystem struct {
|
||||
OsType string
|
||||
OsVersions []string
|
||||
}
|
||||
|
||||
func newPostureCheckOperatingSystem() PostureCheckSubType {
|
||||
return &PostureCheckOperatingSystem{
|
||||
OperatingSystems: []OperatingSystem{},
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *PostureCheckOperatingSystem) LoadValues(_ boltz.CrudStore, bucket *boltz.TypedBucket) {
|
||||
|
||||
cursor := bucket.Cursor()
|
||||
|
||||
for key, _ := cursor.First(); key != nil; key, _ = cursor.Next() {
|
||||
osBucket := bucket.GetBucket(string(key))
|
||||
newOsMatch := OperatingSystem{
|
||||
OsType: osBucket.GetStringOrError(FieldPostureCheckOsType),
|
||||
}
|
||||
|
||||
for _, osVersion := range osBucket.GetStringList(FieldPostureCheckOsVersions) {
|
||||
newOsMatch.OsVersions = append(newOsMatch.OsVersions, osVersion)
|
||||
}
|
||||
entity.OperatingSystems = append(entity.OperatingSystems, newOsMatch)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (entity *PostureCheckOperatingSystem) SetValues(ctx *boltz.PersistContext, bucket *boltz.TypedBucket) {
|
||||
osMap := map[string]OperatingSystem{}
|
||||
|
||||
for _, os := range entity.OperatingSystems {
|
||||
osMap[os.OsType] = os
|
||||
}
|
||||
|
||||
cursor := bucket.Cursor()
|
||||
for key, _ := cursor.First(); key != nil; key, _ = cursor.Next() {
|
||||
if _, found := osMap[string(key)]; !found {
|
||||
_ = bucket.Delete(key)
|
||||
}
|
||||
}
|
||||
|
||||
for _, os := range entity.OperatingSystems {
|
||||
existing := bucket.GetOrCreateBucket(os.OsType)
|
||||
existing.SetString(FieldPostureCheckOsType, os.OsType, ctx.FieldChecker)
|
||||
existing.SetStringList(FieldPostureCheckOsVersions, os.OsVersions, ctx.FieldChecker)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
)
|
||||
|
||||
const (
|
||||
FieldPostureCheckProcessOs = "os"
|
||||
FieldPostureCheckProcessPath = "path"
|
||||
FieldPostureCheckProcessHashes = "hashes"
|
||||
FieldPostureCheckProcessFingerprint = "fingerprint"
|
||||
)
|
||||
|
||||
type PostureCheckProcess struct {
|
||||
OperatingSystem string
|
||||
Path string
|
||||
Hashes []string
|
||||
Fingerprint string
|
||||
}
|
||||
|
||||
func newPostureCheckProcess() PostureCheckSubType {
|
||||
return &PostureCheckProcess{
|
||||
OperatingSystem: "",
|
||||
Path: "",
|
||||
Hashes: []string{},
|
||||
Fingerprint: "",
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *PostureCheckProcess) LoadValues(_ boltz.CrudStore, bucket *boltz.TypedBucket) {
|
||||
entity.OperatingSystem = bucket.GetStringOrError(FieldPostureCheckProcessOs)
|
||||
entity.Path = bucket.GetStringOrError(FieldPostureCheckProcessPath)
|
||||
entity.Hashes = bucket.GetStringList(FieldPostureCheckProcessHashes)
|
||||
entity.Fingerprint = bucket.GetStringOrError(FieldPostureCheckProcessFingerprint)
|
||||
}
|
||||
|
||||
func (entity *PostureCheckProcess) SetValues(ctx *boltz.PersistContext, bucket *boltz.TypedBucket) {
|
||||
bucket.SetString(FieldPostureCheckProcessOs, entity.OperatingSystem, ctx.FieldChecker)
|
||||
bucket.SetString(FieldPostureCheckProcessPath, entity.Path, ctx.FieldChecker)
|
||||
bucket.SetStringList(FieldPostureCheckProcessHashes, entity.Hashes, ctx.FieldChecker)
|
||||
bucket.SetString(FieldPostureCheckProcessFingerprint, entity.Fingerprint, ctx.FieldChecker)
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
const (
|
||||
FieldPostureCheckTypeOperatingSystems = "operatingSystems"
|
||||
)
|
||||
|
||||
type PostureCheckType struct {
|
||||
boltz.BaseExtEntity
|
||||
Name string
|
||||
OperatingSystems []OperatingSystem
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) GetName() string {
|
||||
return entity.Name
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) LoadValues(_ boltz.CrudStore, bucket *boltz.TypedBucket) {
|
||||
entity.LoadBaseValues(bucket)
|
||||
entity.Name = bucket.GetStringOrError(FieldName)
|
||||
|
||||
osBucket := bucket.GetOrCreateBucket(FieldPostureCheckTypeOperatingSystems)
|
||||
cursor := osBucket.Cursor()
|
||||
|
||||
for key, _ := cursor.First(); key != nil; key, _ = cursor.Next() {
|
||||
curOs := osBucket.GetBucket(string(key))
|
||||
|
||||
if curOs == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
newOsMatch := OperatingSystem{
|
||||
OsType: curOs.GetStringOrError(FieldPostureCheckOsType),
|
||||
}
|
||||
|
||||
for _, osVersion := range curOs.GetStringList(FieldPostureCheckOsVersions) {
|
||||
newOsMatch.OsVersions = append(newOsMatch.OsVersions, osVersion)
|
||||
}
|
||||
entity.OperatingSystems = append(entity.OperatingSystems, newOsMatch)
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) SetValues(ctx *boltz.PersistContext) {
|
||||
entity.SetBaseValues(ctx)
|
||||
ctx.SetString(FieldName, entity.Name)
|
||||
|
||||
osMap := map[string]OperatingSystem{}
|
||||
|
||||
for _, os := range entity.OperatingSystems {
|
||||
osMap[os.OsType] = os
|
||||
}
|
||||
|
||||
osBucket := ctx.Bucket.GetOrCreateBucket(FieldPostureCheckTypeOperatingSystems)
|
||||
cursor := osBucket.Cursor()
|
||||
|
||||
for key, _ := cursor.First(); key != nil; key, _ = cursor.Next() {
|
||||
if _, found := osMap[string(key)]; !found {
|
||||
_ = osBucket.Delete(key)
|
||||
}
|
||||
}
|
||||
|
||||
for _, os := range entity.OperatingSystems {
|
||||
existing := osBucket.GetOrCreateBucket(os.OsType)
|
||||
existing.SetString(FieldPostureCheckOsType, os.OsType, ctx.FieldChecker)
|
||||
existing.SetStringList(FieldPostureCheckOsVersions, os.OsVersions, ctx.FieldChecker)
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *PostureCheckType) GetEntityType() string {
|
||||
return EntityTypePostureCheckTypes
|
||||
}
|
||||
|
||||
type PostureCheckTypeStore interface {
|
||||
NameIndexedStore
|
||||
LoadOneById(tx *bbolt.Tx, id string) (*PostureCheckType, error)
|
||||
LoadOneByName(tx *bbolt.Tx, id string) (*PostureCheckType, error)
|
||||
}
|
||||
|
||||
func newPostureCheckTypeStore(stores *stores) *postureCheckTypeStoreImpl {
|
||||
store := &postureCheckTypeStoreImpl{
|
||||
baseStore: newBaseStore(stores, EntityTypePostureCheckTypes),
|
||||
}
|
||||
store.InitImpl(store)
|
||||
return store
|
||||
}
|
||||
|
||||
type postureCheckTypeStoreImpl struct {
|
||||
*baseStore
|
||||
indexName boltz.ReadIndex
|
||||
}
|
||||
|
||||
func (store *postureCheckTypeStoreImpl) NewStoreEntity() boltz.Entity {
|
||||
return &PostureCheckType{}
|
||||
}
|
||||
|
||||
func (store *postureCheckTypeStoreImpl) initializeLocal() {
|
||||
store.AddExtEntitySymbols()
|
||||
store.indexName = store.addUniqueNameField()
|
||||
}
|
||||
|
||||
func (store *postureCheckTypeStoreImpl) initializeLinked() {
|
||||
// no links
|
||||
}
|
||||
|
||||
func (store *postureCheckTypeStoreImpl) GetNameIndex() boltz.ReadIndex {
|
||||
return store.indexName
|
||||
}
|
||||
|
||||
func (store *postureCheckTypeStoreImpl) LoadOneById(tx *bbolt.Tx, id string) (*PostureCheckType, error) {
|
||||
entity := &PostureCheckType{}
|
||||
if err := store.baseLoadOneById(tx, id, entity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entity, nil
|
||||
}
|
||||
|
||||
func (store *postureCheckTypeStoreImpl) LoadOneByName(tx *bbolt.Tx, name string) (*PostureCheckType, error) {
|
||||
id := store.indexName.Read(tx, []byte(name))
|
||||
if id != nil {
|
||||
return store.LoadOneById(tx, string(id))
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (store *postureCheckTypeStoreImpl) LoadOneByQuery(tx *bbolt.Tx, query string) (*PostureCheckType, error) {
|
||||
entity := &PostureCheckType{}
|
||||
if found, err := store.BaseLoadOneByQuery(tx, query, entity); !found || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return entity, nil
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright NetFoundry, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
)
|
||||
|
||||
const (
|
||||
FieldPostureCheckDomains = "domains"
|
||||
)
|
||||
|
||||
type PostureCheckWindowsDomains struct {
|
||||
Domains []string
|
||||
}
|
||||
|
||||
func newPostureCheckWindowsDomain() PostureCheckSubType {
|
||||
return &PostureCheckWindowsDomains{
|
||||
Domains: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *PostureCheckWindowsDomains) LoadValues(_ boltz.CrudStore, bucket *boltz.TypedBucket) {
|
||||
entity.Domains = bucket.GetStringList(FieldPostureCheckDomains)
|
||||
}
|
||||
|
||||
func (entity *PostureCheckWindowsDomains) SetValues(ctx *boltz.PersistContext, bucket *boltz.TypedBucket) {
|
||||
bucket.SetStringList(FieldPostureCheckDomains, entity.Domains, ctx.FieldChecker)
|
||||
}
|
||||
@@ -39,11 +39,12 @@ func newServicePolicy(name string) *ServicePolicy {
|
||||
|
||||
type ServicePolicy struct {
|
||||
boltz.BaseExtEntity
|
||||
PolicyType int32
|
||||
Name string
|
||||
Semantic string
|
||||
IdentityRoles []string
|
||||
ServiceRoles []string
|
||||
PolicyType int32
|
||||
Name string
|
||||
Semantic string
|
||||
IdentityRoles []string
|
||||
ServiceRoles []string
|
||||
PostureCheckRoles []string
|
||||
}
|
||||
|
||||
func (entity *ServicePolicy) GetName() string {
|
||||
@@ -61,6 +62,7 @@ func (entity *ServicePolicy) LoadValues(_ boltz.CrudStore, bucket *boltz.TypedBu
|
||||
entity.Semantic = bucket.GetStringWithDefault(FieldSemantic, SemanticAllOf)
|
||||
entity.IdentityRoles = bucket.GetStringList(FieldIdentityRoles)
|
||||
entity.ServiceRoles = bucket.GetStringList(FieldServiceRoles)
|
||||
entity.PostureCheckRoles = bucket.GetStringList(FieldPostureCheckRoles)
|
||||
}
|
||||
|
||||
func (entity *ServicePolicy) SetValues(ctx *boltz.PersistContext) {
|
||||
@@ -81,6 +83,10 @@ func (entity *ServicePolicy) SetValues(ctx *boltz.PersistContext) {
|
||||
ctx.Bucket.SetError(err)
|
||||
}
|
||||
|
||||
if err := validateRolesAndIds(FieldPostureCheckRoles, entity.PostureCheckRoles); err != nil {
|
||||
ctx.Bucket.SetError(err)
|
||||
}
|
||||
|
||||
if ctx.ProceedWithSet(FieldSemantic) && !isSemanticValid(entity.Semantic) {
|
||||
ctx.Bucket.SetError(validation.NewFieldError("invalid semantic", FieldSemantic, entity.Semantic))
|
||||
return
|
||||
@@ -99,10 +105,16 @@ func (entity *ServicePolicy) SetValues(ctx *boltz.PersistContext) {
|
||||
if valueSet && !stringz.EqualSlices(oldIdentityRoles, entity.IdentityRoles) {
|
||||
servicePolicyStore.identityRolesUpdated(ctx, entity)
|
||||
}
|
||||
|
||||
oldServiceRoles, valueSet := ctx.GetAndSetStringList(FieldServiceRoles, entity.ServiceRoles)
|
||||
if valueSet && !stringz.EqualSlices(oldServiceRoles, entity.ServiceRoles) {
|
||||
servicePolicyStore.serviceRolesUpdated(ctx, entity)
|
||||
}
|
||||
|
||||
oldPostureCheckRoles, valueSet := ctx.GetAndSetStringList(FieldPostureCheckRoles, entity.PostureCheckRoles)
|
||||
if valueSet && !stringz.EqualSlices(oldPostureCheckRoles, entity.PostureCheckRoles) {
|
||||
servicePolicyStore.postureCheckRolesUpdated(ctx, entity)
|
||||
}
|
||||
}
|
||||
|
||||
func (entity *ServicePolicy) GetEntityType() string {
|
||||
@@ -147,9 +159,11 @@ type servicePolicyStoreImpl struct {
|
||||
symbolServiceRoles boltz.EntitySetSymbol
|
||||
symbolIdentities boltz.EntitySetSymbol
|
||||
symbolServices boltz.EntitySetSymbol
|
||||
symbolPostureChecks boltz.EntitySetSymbol
|
||||
|
||||
identityCollection boltz.LinkCollection
|
||||
serviceCollection boltz.LinkCollection
|
||||
identityCollection boltz.LinkCollection
|
||||
serviceCollection boltz.LinkCollection
|
||||
postureCheckCollection boltz.LinkCollection
|
||||
}
|
||||
|
||||
func (store *servicePolicyStoreImpl) GetNameIndex() boltz.ReadIndex {
|
||||
@@ -170,11 +184,13 @@ func (store *servicePolicyStoreImpl) initializeLocal() {
|
||||
store.symbolServiceRoles = store.AddSetSymbol(FieldServiceRoles, ast.NodeTypeString)
|
||||
store.symbolIdentities = store.AddFkSetSymbol(EntityTypeIdentities, store.stores.identity)
|
||||
store.symbolServices = store.AddFkSetSymbol(db.EntityTypeServices, store.stores.edgeService)
|
||||
store.symbolPostureChecks = store.AddFkSetSymbol(EntityTypePostureChecks, store.stores.postureCheck)
|
||||
}
|
||||
|
||||
func (store *servicePolicyStoreImpl) initializeLinked() {
|
||||
store.serviceCollection = store.AddLinkCollection(store.symbolServices, store.stores.edgeService.symbolServicePolicies)
|
||||
store.identityCollection = store.AddLinkCollection(store.symbolIdentities, store.stores.identity.symbolServicePolicies)
|
||||
store.postureCheckCollection = store.AddLinkCollection(store.symbolPostureChecks, store.stores.postureCheck.symbolServicePolicies)
|
||||
}
|
||||
|
||||
func (store *servicePolicyStoreImpl) LoadOneById(tx *bbolt.Tx, id string) (*ServicePolicy, error) {
|
||||
@@ -234,6 +250,24 @@ func (store *servicePolicyStoreImpl) identityRolesUpdated(persistCtx *boltz.Pers
|
||||
EvaluatePolicy(ctx, policy, store.stores.identity.symbolRoleAttributes)
|
||||
}
|
||||
|
||||
func (store *servicePolicyStoreImpl) postureCheckRolesUpdated(persistCtx *boltz.PersistContext, policy *ServicePolicy) {
|
||||
ctx := &roleAttributeChangeContext{
|
||||
tx: persistCtx.Bucket.Tx(),
|
||||
rolesSymbol: store.symbolPostureChecks,
|
||||
linkCollection: store.postureCheckCollection,
|
||||
relatedLinkCollection: store.serviceCollection,
|
||||
ErrorHolder: persistCtx.Bucket,
|
||||
}
|
||||
|
||||
if policy.PolicyType == PolicyTypeDial {
|
||||
ctx.denormLinkCollection = store.stores.identity.dialServicesCollection
|
||||
} else {
|
||||
ctx.denormLinkCollection = store.stores.identity.bindServicesCollection
|
||||
}
|
||||
|
||||
EvaluatePolicy(ctx, policy, store.stores.postureCheck.symbolRoleAttributes)
|
||||
}
|
||||
|
||||
func (store *servicePolicyStoreImpl) DeleteById(ctx boltz.MutateContext, id string) error {
|
||||
policy, err := store.LoadOneById(ctx.Tx(), id)
|
||||
if err != nil {
|
||||
|
||||
@@ -54,6 +54,7 @@ type Stores struct {
|
||||
Enrollment EnrollmentStore
|
||||
Authenticator AuthenticatorStore
|
||||
PostureCheck PostureCheckStore
|
||||
PostureCheckType PostureCheckTypeStore
|
||||
|
||||
storeMap map[reflect.Type]boltz.CrudStore
|
||||
}
|
||||
@@ -139,6 +140,7 @@ type stores struct {
|
||||
enrollment *enrollmentStoreImpl
|
||||
authenticator *authenticatorStoreImpl
|
||||
postureCheck *postureCheckStoreImpl
|
||||
postureCheckType *postureCheckTypeStoreImpl
|
||||
}
|
||||
|
||||
func NewBoltStores(dbProvider DbProvider) (*Stores, error) {
|
||||
@@ -170,6 +172,7 @@ func NewBoltStores(dbProvider DbProvider) (*Stores, error) {
|
||||
internalStores.servicePolicy = newServicePolicyStore(internalStores)
|
||||
internalStores.session = newSessionStore(internalStores)
|
||||
internalStores.postureCheck = newPostureCheckStore(internalStores)
|
||||
internalStores.postureCheckType = newPostureCheckTypeStore(internalStores)
|
||||
|
||||
externalStores := &Stores{
|
||||
DbProvider: dbProvider,
|
||||
@@ -196,6 +199,7 @@ func NewBoltStores(dbProvider DbProvider) (*Stores, error) {
|
||||
Authenticator: internalStores.authenticator,
|
||||
Enrollment: internalStores.enrollment,
|
||||
PostureCheck: internalStores.postureCheck,
|
||||
PostureCheckType: internalStores.postureCheckType,
|
||||
|
||||
storeMap: make(map[reflect.Type]boltz.CrudStore),
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ type PostureCheckCreate interface {
|
||||
Name() *string
|
||||
SetName(*string)
|
||||
|
||||
// role attributes
|
||||
RoleAttributes() Attributes
|
||||
SetRoleAttributes(Attributes)
|
||||
|
||||
// tags
|
||||
Tags() Tags
|
||||
SetTags(Tags)
|
||||
@@ -76,6 +80,8 @@ type postureCheckCreate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
typeIdField PostureCheckType
|
||||
@@ -101,6 +107,16 @@ func (m *postureCheckCreate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this polymorphic type
|
||||
func (m *postureCheckCreate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this polymorphic type
|
||||
func (m *postureCheckCreate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this polymorphic type
|
||||
func (m *postureCheckCreate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -212,6 +228,10 @@ func (m *postureCheckCreate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -240,6 +260,22 @@ func (m *postureCheckCreate) validateName(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckCreate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckCreate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -73,16 +73,16 @@ type PostureCheckDetail interface {
|
||||
Name() *string
|
||||
SetName(*string)
|
||||
|
||||
// role attributes
|
||||
// Required: true
|
||||
RoleAttributes() Attributes
|
||||
SetRoleAttributes(Attributes)
|
||||
|
||||
// tags
|
||||
// Required: true
|
||||
Tags() Tags
|
||||
SetTags(Tags)
|
||||
|
||||
// type
|
||||
// Required: true
|
||||
Type() *string
|
||||
SetType(*string)
|
||||
|
||||
// type Id
|
||||
// Required: true
|
||||
TypeID() string
|
||||
@@ -114,9 +114,9 @@ type postureCheckDetail struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
tagsField Tags
|
||||
roleAttributesField Attributes
|
||||
|
||||
typeField *string
|
||||
tagsField Tags
|
||||
|
||||
typeIdField string
|
||||
|
||||
@@ -175,6 +175,16 @@ func (m *postureCheckDetail) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this polymorphic type
|
||||
func (m *postureCheckDetail) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this polymorphic type
|
||||
func (m *postureCheckDetail) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this polymorphic type
|
||||
func (m *postureCheckDetail) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -185,16 +195,6 @@ func (m *postureCheckDetail) SetTags(val Tags) {
|
||||
m.tagsField = val
|
||||
}
|
||||
|
||||
// Type gets the type of this polymorphic type
|
||||
func (m *postureCheckDetail) Type() *string {
|
||||
return m.typeField
|
||||
}
|
||||
|
||||
// SetType sets the type of this polymorphic type
|
||||
func (m *postureCheckDetail) SetType(val *string) {
|
||||
m.typeField = val
|
||||
}
|
||||
|
||||
// TypeID gets the type Id of this polymorphic type
|
||||
func (m *postureCheckDetail) TypeID() string {
|
||||
return "PostureCheckDetail"
|
||||
@@ -328,11 +328,11 @@ func (m *postureCheckDetail) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateType(formats); err != nil {
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
@@ -402,11 +402,15 @@ func (m *postureCheckDetail) validateName(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckDetail) validateTags(formats strfmt.Registry) error {
|
||||
func (m *postureCheckDetail) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if err := m.Tags().Validate(formats); err != nil {
|
||||
if err := validate.Required("roleAttributes", "body", m.RoleAttributes()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("tags")
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -414,9 +418,12 @@ func (m *postureCheckDetail) validateTags(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckDetail) validateType(formats strfmt.Registry) error {
|
||||
func (m *postureCheckDetail) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("type", "body", m.Type()); err != nil {
|
||||
if err := m.Tags().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("tags")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckDomainCreate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// domains
|
||||
@@ -75,6 +77,16 @@ func (m *PostureCheckDomainCreate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainCreate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainCreate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckDomainCreate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -118,6 +130,8 @@ func (m *PostureCheckDomainCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -136,6 +150,8 @@ func (m *PostureCheckDomainCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -172,6 +188,8 @@ func (m PostureCheckDomainCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -181,6 +199,8 @@ func (m PostureCheckDomainCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -204,6 +224,10 @@ func (m *PostureCheckDomainCreate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -236,6 +260,22 @@ func (m *PostureCheckDomainCreate) validateName(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainCreate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainCreate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -53,9 +53,9 @@ type PostureCheckDomainDetail struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
tagsField Tags
|
||||
roleAttributesField Attributes
|
||||
|
||||
typeField *string
|
||||
tagsField Tags
|
||||
|
||||
updatedAtField *strfmt.DateTime
|
||||
|
||||
@@ -117,6 +117,16 @@ func (m *PostureCheckDomainDetail) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainDetail) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainDetail) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckDomainDetail) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -127,16 +137,6 @@ func (m *PostureCheckDomainDetail) SetTags(val Tags) {
|
||||
m.tagsField = val
|
||||
}
|
||||
|
||||
// Type gets the type of this subtype
|
||||
func (m *PostureCheckDomainDetail) Type() *string {
|
||||
return m.typeField
|
||||
}
|
||||
|
||||
// SetType sets the type of this subtype
|
||||
func (m *PostureCheckDomainDetail) SetType(val *string) {
|
||||
m.typeField = val
|
||||
}
|
||||
|
||||
// TypeID gets the type Id of this subtype
|
||||
func (m *PostureCheckDomainDetail) TypeID() string {
|
||||
return "DOMAIN"
|
||||
@@ -196,9 +196,9 @@ func (m *PostureCheckDomainDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -226,9 +226,9 @@ func (m *PostureCheckDomainDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.tagsField = base.Tags
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.typeField = base.Type
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
/* Not the type we're looking for. */
|
||||
@@ -273,9 +273,9 @@ func (m PostureCheckDomainDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -294,9 +294,9 @@ func (m PostureCheckDomainDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Type: m.Type(),
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
|
||||
@@ -335,11 +335,11 @@ func (m *PostureCheckDomainDetail) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateType(formats); err != nil {
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
@@ -417,6 +417,22 @@ func (m *PostureCheckDomainDetail) validateName(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainDetail) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("roleAttributes", "body", m.RoleAttributes()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainDetail) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("tags", "body", m.Tags()); err != nil {
|
||||
@@ -433,15 +449,6 @@ func (m *PostureCheckDomainDetail) validateTags(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainDetail) validateType(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("type", "body", m.Type()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainDetail) validateUpdatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("updatedAt", "body", m.UpdatedAt()); err != nil {
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckDomainPatch struct {
|
||||
|
||||
nameField string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// domains
|
||||
@@ -74,6 +76,16 @@ func (m *PostureCheckDomainPatch) SetName(val string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainPatch) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainPatch) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckDomainPatch) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -107,6 +119,8 @@ func (m *PostureCheckDomainPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}
|
||||
buf = bytes.NewBuffer(raw)
|
||||
@@ -123,6 +137,8 @@ func (m *PostureCheckDomainPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
result.Domains = data.Domains
|
||||
@@ -153,6 +169,8 @@ func (m PostureCheckDomainPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}{
|
||||
|
||||
@@ -160,6 +178,8 @@ func (m PostureCheckDomainPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
})
|
||||
if err != nil {
|
||||
@@ -173,6 +193,10 @@ func (m PostureCheckDomainPatch) MarshalJSON() ([]byte, error) {
|
||||
func (m *PostureCheckDomainPatch) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -187,6 +211,22 @@ func (m *PostureCheckDomainPatch) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainPatch) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainPatch) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckDomainUpdate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// domains
|
||||
@@ -75,6 +77,16 @@ func (m *PostureCheckDomainUpdate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainUpdate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckDomainUpdate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckDomainUpdate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -118,6 +130,8 @@ func (m *PostureCheckDomainUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -136,6 +150,8 @@ func (m *PostureCheckDomainUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -172,6 +188,8 @@ func (m PostureCheckDomainUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -181,6 +199,8 @@ func (m PostureCheckDomainUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -204,6 +224,10 @@ func (m *PostureCheckDomainUpdate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -236,6 +260,22 @@ func (m *PostureCheckDomainUpdate) validateName(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainUpdate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckDomainUpdate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckMacAddressCreate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// mac addresses
|
||||
@@ -75,6 +77,16 @@ func (m *PostureCheckMacAddressCreate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressCreate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressCreate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckMacAddressCreate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -118,6 +130,8 @@ func (m *PostureCheckMacAddressCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -136,6 +150,8 @@ func (m *PostureCheckMacAddressCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -172,6 +188,8 @@ func (m PostureCheckMacAddressCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -181,6 +199,8 @@ func (m PostureCheckMacAddressCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -204,6 +224,10 @@ func (m *PostureCheckMacAddressCreate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -236,6 +260,22 @@ func (m *PostureCheckMacAddressCreate) validateName(formats strfmt.Registry) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressCreate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressCreate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -53,9 +53,9 @@ type PostureCheckMacAddressDetail struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
tagsField Tags
|
||||
roleAttributesField Attributes
|
||||
|
||||
typeField *string
|
||||
tagsField Tags
|
||||
|
||||
updatedAtField *strfmt.DateTime
|
||||
|
||||
@@ -117,6 +117,16 @@ func (m *PostureCheckMacAddressDetail) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressDetail) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressDetail) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckMacAddressDetail) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -127,16 +137,6 @@ func (m *PostureCheckMacAddressDetail) SetTags(val Tags) {
|
||||
m.tagsField = val
|
||||
}
|
||||
|
||||
// Type gets the type of this subtype
|
||||
func (m *PostureCheckMacAddressDetail) Type() *string {
|
||||
return m.typeField
|
||||
}
|
||||
|
||||
// SetType sets the type of this subtype
|
||||
func (m *PostureCheckMacAddressDetail) SetType(val *string) {
|
||||
m.typeField = val
|
||||
}
|
||||
|
||||
// TypeID gets the type Id of this subtype
|
||||
func (m *PostureCheckMacAddressDetail) TypeID() string {
|
||||
return "MAC"
|
||||
@@ -196,9 +196,9 @@ func (m *PostureCheckMacAddressDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -226,9 +226,9 @@ func (m *PostureCheckMacAddressDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.tagsField = base.Tags
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.typeField = base.Type
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
/* Not the type we're looking for. */
|
||||
@@ -273,9 +273,9 @@ func (m PostureCheckMacAddressDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -294,9 +294,9 @@ func (m PostureCheckMacAddressDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Type: m.Type(),
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
|
||||
@@ -335,11 +335,11 @@ func (m *PostureCheckMacAddressDetail) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateType(formats); err != nil {
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
@@ -417,6 +417,22 @@ func (m *PostureCheckMacAddressDetail) validateName(formats strfmt.Registry) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressDetail) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("roleAttributes", "body", m.RoleAttributes()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressDetail) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("tags", "body", m.Tags()); err != nil {
|
||||
@@ -433,15 +449,6 @@ func (m *PostureCheckMacAddressDetail) validateTags(formats strfmt.Registry) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressDetail) validateType(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("type", "body", m.Type()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressDetail) validateUpdatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("updatedAt", "body", m.UpdatedAt()); err != nil {
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckMacAddressPatch struct {
|
||||
|
||||
nameField string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// mac addresses
|
||||
@@ -74,6 +76,16 @@ func (m *PostureCheckMacAddressPatch) SetName(val string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressPatch) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressPatch) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckMacAddressPatch) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -107,6 +119,8 @@ func (m *PostureCheckMacAddressPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}
|
||||
buf = bytes.NewBuffer(raw)
|
||||
@@ -123,6 +137,8 @@ func (m *PostureCheckMacAddressPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
result.MacAddresses = data.MacAddresses
|
||||
@@ -153,6 +169,8 @@ func (m PostureCheckMacAddressPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}{
|
||||
|
||||
@@ -160,6 +178,8 @@ func (m PostureCheckMacAddressPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
})
|
||||
if err != nil {
|
||||
@@ -173,6 +193,10 @@ func (m PostureCheckMacAddressPatch) MarshalJSON() ([]byte, error) {
|
||||
func (m *PostureCheckMacAddressPatch) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -187,6 +211,22 @@ func (m *PostureCheckMacAddressPatch) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressPatch) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressPatch) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckMacAddressUpdate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// mac addresses
|
||||
@@ -75,6 +77,16 @@ func (m *PostureCheckMacAddressUpdate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressUpdate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckMacAddressUpdate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckMacAddressUpdate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -118,6 +130,8 @@ func (m *PostureCheckMacAddressUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -136,6 +150,8 @@ func (m *PostureCheckMacAddressUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -172,6 +188,8 @@ func (m PostureCheckMacAddressUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -181,6 +199,8 @@ func (m PostureCheckMacAddressUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -204,6 +224,10 @@ func (m *PostureCheckMacAddressUpdate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -236,6 +260,22 @@ func (m *PostureCheckMacAddressUpdate) validateName(formats strfmt.Registry) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressUpdate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckMacAddressUpdate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckOperatingSystemCreate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// operating systems
|
||||
@@ -74,6 +76,16 @@ func (m *PostureCheckOperatingSystemCreate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemCreate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemCreate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckOperatingSystemCreate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -116,6 +128,8 @@ func (m *PostureCheckOperatingSystemCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -134,6 +148,8 @@ func (m *PostureCheckOperatingSystemCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -169,6 +185,8 @@ func (m PostureCheckOperatingSystemCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -178,6 +196,8 @@ func (m PostureCheckOperatingSystemCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -201,6 +221,10 @@ func (m *PostureCheckOperatingSystemCreate) Validate(formats strfmt.Registry) er
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -233,6 +257,22 @@ func (m *PostureCheckOperatingSystemCreate) validateName(formats strfmt.Registry
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemCreate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemCreate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -53,9 +53,9 @@ type PostureCheckOperatingSystemDetail struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
tagsField Tags
|
||||
roleAttributesField Attributes
|
||||
|
||||
typeField *string
|
||||
tagsField Tags
|
||||
|
||||
updatedAtField *strfmt.DateTime
|
||||
|
||||
@@ -116,6 +116,16 @@ func (m *PostureCheckOperatingSystemDetail) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemDetail) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemDetail) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckOperatingSystemDetail) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -126,16 +136,6 @@ func (m *PostureCheckOperatingSystemDetail) SetTags(val Tags) {
|
||||
m.tagsField = val
|
||||
}
|
||||
|
||||
// Type gets the type of this subtype
|
||||
func (m *PostureCheckOperatingSystemDetail) Type() *string {
|
||||
return m.typeField
|
||||
}
|
||||
|
||||
// SetType sets the type of this subtype
|
||||
func (m *PostureCheckOperatingSystemDetail) SetType(val *string) {
|
||||
m.typeField = val
|
||||
}
|
||||
|
||||
// TypeID gets the type Id of this subtype
|
||||
func (m *PostureCheckOperatingSystemDetail) TypeID() string {
|
||||
return "OS"
|
||||
@@ -194,9 +194,9 @@ func (m *PostureCheckOperatingSystemDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -224,9 +224,9 @@ func (m *PostureCheckOperatingSystemDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.tagsField = base.Tags
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.typeField = base.Type
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
/* Not the type we're looking for. */
|
||||
@@ -270,9 +270,9 @@ func (m PostureCheckOperatingSystemDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -291,9 +291,9 @@ func (m PostureCheckOperatingSystemDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Type: m.Type(),
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
|
||||
@@ -332,11 +332,11 @@ func (m *PostureCheckOperatingSystemDetail) Validate(formats strfmt.Registry) er
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateType(formats); err != nil {
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
@@ -414,6 +414,22 @@ func (m *PostureCheckOperatingSystemDetail) validateName(formats strfmt.Registry
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemDetail) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("roleAttributes", "body", m.RoleAttributes()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemDetail) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("tags", "body", m.Tags()); err != nil {
|
||||
@@ -430,15 +446,6 @@ func (m *PostureCheckOperatingSystemDetail) validateTags(formats strfmt.Registry
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemDetail) validateType(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("type", "body", m.Type()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemDetail) validateUpdatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("updatedAt", "body", m.UpdatedAt()); err != nil {
|
||||
|
||||
@@ -46,6 +46,8 @@ type PostureCheckOperatingSystemPatch struct {
|
||||
|
||||
nameField string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// operating systems
|
||||
@@ -72,6 +74,16 @@ func (m *PostureCheckOperatingSystemPatch) SetName(val string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemPatch) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemPatch) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckOperatingSystemPatch) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -104,6 +116,8 @@ func (m *PostureCheckOperatingSystemPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}
|
||||
buf = bytes.NewBuffer(raw)
|
||||
@@ -120,6 +134,8 @@ func (m *PostureCheckOperatingSystemPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
result.OperatingSystems = data.OperatingSystems
|
||||
@@ -149,6 +165,8 @@ func (m PostureCheckOperatingSystemPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}{
|
||||
|
||||
@@ -156,6 +174,8 @@ func (m PostureCheckOperatingSystemPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
})
|
||||
if err != nil {
|
||||
@@ -169,6 +189,10 @@ func (m PostureCheckOperatingSystemPatch) MarshalJSON() ([]byte, error) {
|
||||
func (m *PostureCheckOperatingSystemPatch) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -183,6 +207,22 @@ func (m *PostureCheckOperatingSystemPatch) Validate(formats strfmt.Registry) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemPatch) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemPatch) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckOperatingSystemUpdate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// operating systems
|
||||
@@ -74,6 +76,16 @@ func (m *PostureCheckOperatingSystemUpdate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemUpdate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckOperatingSystemUpdate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckOperatingSystemUpdate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -116,6 +128,8 @@ func (m *PostureCheckOperatingSystemUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -134,6 +148,8 @@ func (m *PostureCheckOperatingSystemUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -169,6 +185,8 @@ func (m PostureCheckOperatingSystemUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -178,6 +196,8 @@ func (m PostureCheckOperatingSystemUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -201,6 +221,10 @@ func (m *PostureCheckOperatingSystemUpdate) Validate(formats strfmt.Registry) er
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -233,6 +257,22 @@ func (m *PostureCheckOperatingSystemUpdate) validateName(formats strfmt.Registry
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemUpdate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckOperatingSystemUpdate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -56,6 +56,10 @@ type PostureCheckPatch interface {
|
||||
Name() string
|
||||
SetName(string)
|
||||
|
||||
// role attributes
|
||||
RoleAttributes() Attributes
|
||||
SetRoleAttributes(Attributes)
|
||||
|
||||
// tags
|
||||
Tags() Tags
|
||||
SetTags(Tags)
|
||||
@@ -69,6 +73,8 @@ type postureCheckPatch struct {
|
||||
|
||||
nameField string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
}
|
||||
|
||||
@@ -92,6 +98,16 @@ func (m *postureCheckPatch) SetName(val string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this polymorphic type
|
||||
func (m *postureCheckPatch) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this polymorphic type
|
||||
func (m *postureCheckPatch) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this polymorphic type
|
||||
func (m *postureCheckPatch) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -186,6 +202,10 @@ func unmarshalPostureCheckPatch(data []byte, consumer runtime.Consumer) (Posture
|
||||
func (m *postureCheckPatch) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -196,6 +216,22 @@ func (m *postureCheckPatch) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckPatch) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckPatch) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckProcessCreate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// process
|
||||
@@ -74,6 +76,16 @@ func (m *PostureCheckProcessCreate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessCreate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessCreate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckProcessCreate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -116,6 +128,8 @@ func (m *PostureCheckProcessCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -134,6 +148,8 @@ func (m *PostureCheckProcessCreate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -169,6 +185,8 @@ func (m PostureCheckProcessCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId"`
|
||||
@@ -178,6 +196,8 @@ func (m PostureCheckProcessCreate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -201,6 +221,10 @@ func (m *PostureCheckProcessCreate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -233,6 +257,22 @@ func (m *PostureCheckProcessCreate) validateName(formats strfmt.Registry) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessCreate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessCreate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -53,9 +53,9 @@ type PostureCheckProcessDetail struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
tagsField Tags
|
||||
roleAttributesField Attributes
|
||||
|
||||
typeField *string
|
||||
tagsField Tags
|
||||
|
||||
updatedAtField *strfmt.DateTime
|
||||
|
||||
@@ -116,6 +116,16 @@ func (m *PostureCheckProcessDetail) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessDetail) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessDetail) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckProcessDetail) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -126,16 +136,6 @@ func (m *PostureCheckProcessDetail) SetTags(val Tags) {
|
||||
m.tagsField = val
|
||||
}
|
||||
|
||||
// Type gets the type of this subtype
|
||||
func (m *PostureCheckProcessDetail) Type() *string {
|
||||
return m.typeField
|
||||
}
|
||||
|
||||
// SetType sets the type of this subtype
|
||||
func (m *PostureCheckProcessDetail) SetType(val *string) {
|
||||
m.typeField = val
|
||||
}
|
||||
|
||||
// TypeID gets the type Id of this subtype
|
||||
func (m *PostureCheckProcessDetail) TypeID() string {
|
||||
return "PROCESS"
|
||||
@@ -194,9 +194,9 @@ func (m *PostureCheckProcessDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -224,9 +224,9 @@ func (m *PostureCheckProcessDetail) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.tagsField = base.Tags
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.typeField = base.Type
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
/* Not the type we're looking for. */
|
||||
@@ -270,9 +270,9 @@ func (m PostureCheckProcessDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Type *string `json:"type"`
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID string `json:"typeId"`
|
||||
|
||||
@@ -291,9 +291,9 @@ func (m PostureCheckProcessDetail) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Type: m.Type(),
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
|
||||
@@ -332,11 +332,11 @@ func (m *PostureCheckProcessDetail) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateType(formats); err != nil {
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
@@ -414,6 +414,22 @@ func (m *PostureCheckProcessDetail) validateName(formats strfmt.Registry) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessDetail) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("roleAttributes", "body", m.RoleAttributes()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessDetail) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("tags", "body", m.Tags()); err != nil {
|
||||
@@ -430,15 +446,6 @@ func (m *PostureCheckProcessDetail) validateTags(formats strfmt.Registry) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessDetail) validateType(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("type", "body", m.Type()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessDetail) validateUpdatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("updatedAt", "body", m.UpdatedAt()); err != nil {
|
||||
|
||||
@@ -46,6 +46,8 @@ type PostureCheckProcessPatch struct {
|
||||
|
||||
nameField string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// process
|
||||
@@ -72,6 +74,16 @@ func (m *PostureCheckProcessPatch) SetName(val string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessPatch) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessPatch) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckProcessPatch) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -104,6 +116,8 @@ func (m *PostureCheckProcessPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}
|
||||
buf = bytes.NewBuffer(raw)
|
||||
@@ -120,6 +134,8 @@ func (m *PostureCheckProcessPatch) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
result.Process = data.Process
|
||||
@@ -149,6 +165,8 @@ func (m PostureCheckProcessPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
}{
|
||||
|
||||
@@ -156,6 +174,8 @@ func (m PostureCheckProcessPatch) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
})
|
||||
if err != nil {
|
||||
@@ -169,6 +189,10 @@ func (m PostureCheckProcessPatch) MarshalJSON() ([]byte, error) {
|
||||
func (m *PostureCheckProcessPatch) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -183,6 +207,22 @@ func (m *PostureCheckProcessPatch) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessPatch) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessPatch) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -47,6 +47,8 @@ type PostureCheckProcessUpdate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
// process
|
||||
@@ -74,6 +76,16 @@ func (m *PostureCheckProcessUpdate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessUpdate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this subtype
|
||||
func (m *PostureCheckProcessUpdate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this subtype
|
||||
func (m *PostureCheckProcessUpdate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -116,6 +128,8 @@ func (m *PostureCheckProcessUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -134,6 +148,8 @@ func (m *PostureCheckProcessUpdate) UnmarshalJSON(raw []byte) error {
|
||||
|
||||
result.nameField = base.Name
|
||||
|
||||
result.roleAttributesField = base.RoleAttributes
|
||||
|
||||
result.tagsField = base.Tags
|
||||
|
||||
if base.TypeID != result.TypeID() {
|
||||
@@ -169,6 +185,8 @@ func (m PostureCheckProcessUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name *string `json:"name"`
|
||||
|
||||
RoleAttributes Attributes `json:"roleAttributes"`
|
||||
|
||||
Tags Tags `json:"tags"`
|
||||
|
||||
TypeID PostureCheckType `json:"typeId,omitempty"`
|
||||
@@ -178,6 +196,8 @@ func (m PostureCheckProcessUpdate) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Name: m.Name(),
|
||||
|
||||
RoleAttributes: m.RoleAttributes(),
|
||||
|
||||
Tags: m.Tags(),
|
||||
|
||||
TypeID: m.TypeID(),
|
||||
@@ -201,6 +221,10 @@ func (m *PostureCheckProcessUpdate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -233,6 +257,22 @@ func (m *PostureCheckProcessUpdate) validateName(formats strfmt.Registry) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessUpdate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostureCheckProcessUpdate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -58,6 +58,10 @@ type PostureCheckUpdate interface {
|
||||
Name() *string
|
||||
SetName(*string)
|
||||
|
||||
// role attributes
|
||||
RoleAttributes() Attributes
|
||||
SetRoleAttributes(Attributes)
|
||||
|
||||
// tags
|
||||
Tags() Tags
|
||||
SetTags(Tags)
|
||||
@@ -75,6 +79,8 @@ type postureCheckUpdate struct {
|
||||
|
||||
nameField *string
|
||||
|
||||
roleAttributesField Attributes
|
||||
|
||||
tagsField Tags
|
||||
|
||||
typeIdField PostureCheckType
|
||||
@@ -100,6 +106,16 @@ func (m *postureCheckUpdate) SetName(val *string) {
|
||||
m.nameField = val
|
||||
}
|
||||
|
||||
// RoleAttributes gets the role attributes of this polymorphic type
|
||||
func (m *postureCheckUpdate) RoleAttributes() Attributes {
|
||||
return m.roleAttributesField
|
||||
}
|
||||
|
||||
// SetRoleAttributes sets the role attributes of this polymorphic type
|
||||
func (m *postureCheckUpdate) SetRoleAttributes(val Attributes) {
|
||||
m.roleAttributesField = val
|
||||
}
|
||||
|
||||
// Tags gets the tags of this polymorphic type
|
||||
func (m *postureCheckUpdate) Tags() Tags {
|
||||
return m.tagsField
|
||||
@@ -211,6 +227,10 @@ func (m *postureCheckUpdate) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRoleAttributes(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTags(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -239,6 +259,22 @@ func (m *postureCheckUpdate) validateName(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckUpdate) validateRoleAttributes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoleAttributes()) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.RoleAttributes().Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("roleAttributes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *postureCheckUpdate) validateTags(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Tags()) { // not required
|
||||
|
||||
@@ -45,7 +45,8 @@ type ServiceCreate struct {
|
||||
Configs []string `json:"configs"`
|
||||
|
||||
// encryption required
|
||||
EncryptionRequired bool `json:"encryptionRequired,omitempty"`
|
||||
// Required: true
|
||||
EncryptionRequired *bool `json:"encryptionRequired"`
|
||||
|
||||
// name
|
||||
// Required: true
|
||||
@@ -65,6 +66,10 @@ type ServiceCreate struct {
|
||||
func (m *ServiceCreate) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateEncryptionRequired(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateName(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -79,6 +84,15 @@ func (m *ServiceCreate) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ServiceCreate) validateEncryptionRequired(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("encryptionRequired", "body", m.EncryptionRequired); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ServiceCreate) validateName(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("name", "body", m.Name); err != nil {
|
||||
|
||||
@@ -4878,6 +4878,9 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
},
|
||||
@@ -4891,10 +4894,10 @@ func init() {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"type",
|
||||
"typeId",
|
||||
"description",
|
||||
"version",
|
||||
"roleAttributes",
|
||||
"id",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
@@ -4918,12 +4921,12 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"typeId": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -5203,6 +5206,9 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
}
|
||||
@@ -5327,6 +5333,9 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
},
|
||||
@@ -7997,7 +8006,8 @@ func init() {
|
||||
"serviceCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
"name",
|
||||
"encryptionRequired"
|
||||
],
|
||||
"properties": {
|
||||
"configs": {
|
||||
@@ -22192,6 +22202,9 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
},
|
||||
@@ -22205,10 +22218,10 @@ func init() {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"type",
|
||||
"typeId",
|
||||
"description",
|
||||
"version",
|
||||
"roleAttributes",
|
||||
"id",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
@@ -22232,12 +22245,12 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"typeId": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -22517,6 +22530,9 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
}
|
||||
@@ -22641,6 +22657,9 @@ func init() {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"roleAttributes": {
|
||||
"$ref": "#/definitions/attributes"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/definitions/tags"
|
||||
},
|
||||
@@ -25311,7 +25330,8 @@ func init() {
|
||||
"serviceCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
"name",
|
||||
"encryptionRequired"
|
||||
],
|
||||
"properties": {
|
||||
"configs": {
|
||||
|
||||
+10
-3
@@ -4925,6 +4925,7 @@ definitions:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- encryptionRequired
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
@@ -6213,10 +6214,10 @@ definitions:
|
||||
# see https://github.com/go-swagger/go-swagger/issues/2413
|
||||
required:
|
||||
- name
|
||||
- type
|
||||
- typeId
|
||||
- description
|
||||
- version
|
||||
- roleAttributes
|
||||
- id
|
||||
- createdAt
|
||||
- updatedAt
|
||||
@@ -6225,14 +6226,14 @@ definitions:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
typeId:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
version:
|
||||
type: integer
|
||||
roleAttributes:
|
||||
$ref: '#/definitions/attributes'
|
||||
id:
|
||||
type: string
|
||||
createdAt:
|
||||
@@ -6259,6 +6260,8 @@ definitions:
|
||||
$ref: '#/definitions/postureCheckType'
|
||||
description:
|
||||
type: string
|
||||
roleAttributes:
|
||||
$ref: '#/definitions/attributes'
|
||||
tags:
|
||||
$ref: '#/definitions/tags'
|
||||
PostureCheckUpdate:
|
||||
@@ -6274,6 +6277,8 @@ definitions:
|
||||
$ref: '#/definitions/postureCheckType'
|
||||
description:
|
||||
type: string
|
||||
roleAttributes:
|
||||
$ref: '#/definitions/attributes'
|
||||
tags:
|
||||
$ref: '#/definitions/tags'
|
||||
PostureCheckPatch:
|
||||
@@ -6284,6 +6289,8 @@ definitions:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
roleAttributes:
|
||||
$ref: '#/definitions/attributes'
|
||||
tags:
|
||||
$ref: '#/definitions/tags'
|
||||
|
||||
|
||||
@@ -538,6 +538,7 @@ func (ctx *TestContext) newService(roleAttributes, configs []string) *service {
|
||||
terminatorStrategy: xt_smartrouting.Name,
|
||||
roleAttributes: roleAttributes,
|
||||
configs: configs,
|
||||
encryptionRequired: false,
|
||||
tags: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ type service struct {
|
||||
configs []string
|
||||
permissions []string
|
||||
tags map[string]interface{}
|
||||
encryptionRequired bool
|
||||
}
|
||||
|
||||
func (entity *service) getId() string {
|
||||
@@ -72,6 +73,7 @@ func (entity *service) toJson(_ bool, ctx *TestContext, _ ...string) string {
|
||||
ctx.setJsonValue(entityData, entity.terminatorStrategy, "terminatorStrategy")
|
||||
ctx.setJsonValue(entityData, entity.roleAttributes, "roleAttributes")
|
||||
ctx.setJsonValue(entityData, entity.configs, "configs")
|
||||
ctx.setJsonValue(entityData, entity.encryptionRequired, "encryptionRequired")
|
||||
|
||||
if len(entity.tags) > 0 {
|
||||
ctx.setJsonValue(entityData, entity.tags, "tags")
|
||||
|
||||
Reference in New Issue
Block a user