Skip to content

Commit

Permalink
fix: took out ControlPrototype/ControlSpecificationPrototype/Assessme…
Browse files Browse the repository at this point in the history
…ntPrototype
  • Loading branch information
tyao117 committed Jan 24, 2025
1 parent 0652a66 commit 53b424c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5229,30 +5229,6 @@ func UnmarshalAssessment(m map[string]json.RawMessage, result interface{}) (err
return
}

// AssessmentPrototype : The necessary fields to include a rule/assessment.
type AssessmentPrototype struct {
// The ID of the rule to target. A list of rules can be obtained from the list_rules method.
AssessmentID *string `json:"assessment_id,omitempty"`

// Details on the intent of the rule for an assessment.
AssessmentDescription *string `json:"assessment_description,omitempty"`
}

// UnmarshalAssessmentPrototype unmarshals an instance of AssessmentPrototype from the specified map of raw messages.
func UnmarshalAssessmentPrototype(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(AssessmentPrototype)
err = core.UnmarshalPrimitive(m, "assessment_id", &obj.AssessmentID)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "assessment_description", &obj.AssessmentDescription)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}

// AssessmentWithStats : The control specification assessment.
type AssessmentWithStats struct {
// The assessment ID.
Expand Down Expand Up @@ -6261,7 +6237,7 @@ type Control struct {
Status *string `json:"status,omitempty"`
}

// UnmarshalControlPrototype unmarshals an instance of ControlPrototype from the specified map of raw messages.
// UnmarshalControl unmarshals an instance of Control from the specified map of raw messages.
func UnmarshalControl(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(Control)
err = core.UnmarshalPrimitive(m, "control_name", &obj.ControlName)
Expand Down Expand Up @@ -6316,45 +6292,9 @@ func UnmarshalControl(m map[string]json.RawMessage, result interface{}) (err err
return
}

// ControlPrototype : The payload to instantiate a control.
type ControlPrototype struct {
// The ID of the control library that contains the profile.
ControlName *string `json:"control_name" validate:"required"`

// The association of the control.
ControlCategory *string `json:"control_category" validate:"required"`

// true if the control can be automated, false if the control cannot. Must be false to be a parent
ControlRequirement *bool `json:"control_requirement" validate:"required"`

// The ID of the control.
ID *string `json:"control_id,omitempty"`

// The control description.
ControlDescription *string `json:"control_description,omitempty"`

// The ID of the parent control.
ControlParent *string `json:"control_parent,omitempty"`

// The Path of the control
ControlPath *string `json:"control_path,omitempty"`

// List of control specifications associated with the control.
ControlSpecifications []ControlSpecificationPrototype `json:"control_specifications" validate:"required"`

// References to a control documentation.
ControlDocs *ControlDoc `json:"control_docs,omitempty"`

// Details if a control library can be used or not.
Status *string `json:"status,omitempty"`

// The Tags associated with the ControlPrototype.
ControlTags []string `json:"control_tags,omitempty"`
}

// NewControlPrototype : Instantiate ControlPrototype (Generic Model Constructor)
func (*SecurityAndComplianceCenterApiV3) NewControlPrototype(controlName string, controlCategory string, controlRequirement bool, controlSpecifications []ControlSpecificationPrototype) (_model *ControlPrototype, err error) {
_model = &ControlPrototype{
// NewControl: Instantiate Control(Generic Model Constructor)
func (*SecurityAndComplianceCenterApiV3) NewControl(controlName string, controlCategory string, controlRequirement bool, controlSpecifications []ControlSpecification) (_model *Control, err error) {
_model = &Control{
ControlName: core.StringPtr(controlName),
ControlCategory: core.StringPtr(controlCategory),
ControlRequirement: core.BoolPtr(controlRequirement),
Expand All @@ -6364,53 +6304,6 @@ func (*SecurityAndComplianceCenterApiV3) NewControlPrototype(controlName string,
return
}

// UnmarshalControlPrototype unmarshals an instance of ControlPrototype from the specified map of raw messages.
func UnmarshalControlPrototype(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(ControlPrototype)
err = core.UnmarshalPrimitive(m, "control_name", &obj.ControlName)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "control_description", &obj.ControlDescription)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "control_category", &obj.ControlCategory)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "control_id", &obj.ID)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "control_requirement", &obj.ControlRequirement)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "control_parent", &obj.ControlParent)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "control_path", &obj.ControlPath)
if err != nil {
return
}
err = core.UnmarshalModel(m, "control_specifications", &obj.ControlSpecifications, UnmarshalControlSpecificationPrototype)
if err != nil {
return
}
err = core.UnmarshalModel(m, "control_docs", &obj.ControlDocs, UnmarshalControlDoc)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "status", &obj.Status)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}

// ControlSpecification : A statement that defines a security/privacy requirement for a Control.
type ControlSpecification struct {
// The ID of the control.
Expand Down Expand Up @@ -6491,57 +6384,6 @@ func UnmarshalControlSpecification(m map[string]json.RawMessage, result interfac
return
}

// ControlSpecificationPrototype : The necessary fields to instantiate a Control Specification.
type ControlSpecificationPrototype struct {
// The ID of the control specification
ID *string `json:"control_specification_id,omitempty"`

// The ID of the component. The component_id can be found from the 'service_name' using the Get Services method.
ComponentID *string `json:"component_id,omitempty"`

// The cloud provider the specification is targeting.
Environment *string `json:"environment,omitempty"`

// Information about the Control Specification.
Description *string `json:"control_specification_description,omitempty"`

// The detailed list of rules associated with the Specification.
Assessments []AssessmentPrototype `json:"assessments,omitempty"`
}

// Constants associated with the ControlSpecificationPrototype.Environment property.
// The cloud provider the specification is targeting.
const (
ControlSpecificationPrototypeEnvironmentIBMCloudConst = "ibm-cloud"
)

// UnmarshalControlSpecificationPrototype unmarshals an instance of ControlSpecificationPrototype from the specified map of raw messages.
func UnmarshalControlSpecificationPrototype(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(ControlSpecificationPrototype)
err = core.UnmarshalPrimitive(m, "control_specification_id", &obj.ID)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "component_id", &obj.ComponentID)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "environment", &obj.Environment)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "control_specification_description", &obj.Description)
if err != nil {
return
}
err = core.UnmarshalModel(m, "assessments", &obj.Assessments, UnmarshalAssessmentPrototype)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}

// ControlSpecificationWithStats : The control specification with compliance stats.
type ControlSpecificationWithStats struct {
// The control specification ID.
Expand Down Expand Up @@ -6848,7 +6690,7 @@ type CreateCustomControlLibraryOptions struct {
ControlLibraryVersion *string `json:"control_library_version" validate:"required"`

// The list of rules that the control library attempts to adhere to.
Controls []ControlPrototype `json:"controls" validate:"required"`
Controls []Control `json:"controls" validate:"required"`

// The user account ID.
AccountID *string `json:"account_id,omitempty"`
Expand All @@ -6870,7 +6712,7 @@ const (
)

// NewCreateCustomControlLibraryOptions : Instantiate CreateCustomControlLibraryOptions
func (*SecurityAndComplianceCenterApiV3) NewCreateCustomControlLibraryOptions(instanceID string, controlLibraryName string, controlLibraryDescription string, controlLibraryType string, controlLibraryVersion string, controls []ControlPrototype) *CreateCustomControlLibraryOptions {
func (*SecurityAndComplianceCenterApiV3) NewCreateCustomControlLibraryOptions(instanceID string, controlLibraryName string, controlLibraryDescription string, controlLibraryType string, controlLibraryVersion string, controls []Control) *CreateCustomControlLibraryOptions {
return &CreateCustomControlLibraryOptions{
InstanceID: core.StringPtr(instanceID),
ControlLibraryName: core.StringPtr(controlLibraryName),
Expand Down Expand Up @@ -6912,7 +6754,7 @@ func (_options *CreateCustomControlLibraryOptions) SetControlLibraryVersion(cont
}

// SetControls : Allow user to set Controls
func (_options *CreateCustomControlLibraryOptions) SetControls(controls []ControlPrototype) *CreateCustomControlLibraryOptions {
func (_options *CreateCustomControlLibraryOptions) SetControls(controls []Control) *CreateCustomControlLibraryOptions {
_options.Controls = controls
return _options
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,26 @@ var _ = Describe(`SecurityAndComplianceCenterV3 Examples Tests`, func() {
fmt.Println("\nCreateCustomControlLibrary() result:")
// begin-create_custom_control_library

assessmentPrototypeModel := &securityandcompliancecenterv3.AssessmentPrototype{
assessmentPrototypeModel := &securityandcompliancecenterv3.Assessment{
AssessmentID: core.StringPtr("rule-d1bd9f3f-bee1-46c5-9533-da8bba9eed4e"),
AssessmentDescription: core.StringPtr("This rule will check on regulation"),
}

controlSpecificationPrototypeModel := &securityandcompliancecenterv3.ControlSpecificationPrototype{
controlSpecificationPrototypeModel := &securityandcompliancecenterv3.ControlSpecification{
ComponentID: core.StringPtr("apprapp"),
Environment: core.StringPtr("ibm-cloud"),
Description: core.StringPtr("This field is used to describe a control specification"),
Assessments: []securityandcompliancecenterv3.AssessmentPrototype{*assessmentPrototypeModel},
Assessments: []securityandcompliancecenterv3.Assessment{*assessmentPrototypeModel},
}

controlDocModel := &securityandcompliancecenterv3.ControlDoc{}

controlPrototypeModel := &securityandcompliancecenterv3.ControlPrototype{
controlPrototypeModel := &securityandcompliancecenterv3.Control{
ControlName: core.StringPtr("security"),
ControlDescription: core.StringPtr("This is a description of a control"),
ControlCategory: core.StringPtr("test-control"),
ControlRequirement: core.BoolPtr(true),
ControlSpecifications: []securityandcompliancecenterv3.ControlSpecificationPrototype{*controlSpecificationPrototypeModel},
ControlSpecifications: []securityandcompliancecenterv3.ControlSpecification{*controlSpecificationPrototypeModel},
ControlDocs: controlDocModel,
Status: core.StringPtr("disabled"),
}
Expand All @@ -245,7 +245,7 @@ var _ = Describe(`SecurityAndComplianceCenterV3 Examples Tests`, func() {
"This is a custom control library made from the SDK test framework",
"custom",
"0.0.1",
[]securityandcompliancecenterv3.ControlPrototype{*controlPrototypeModel},
[]securityandcompliancecenterv3.Control{*controlPrototypeModel},
)

controlLibrary, response, err := securityAndComplianceCenterService.CreateCustomControlLibrary(createCustomControlLibraryOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,27 +267,27 @@ var _ = Describe(`SecurityAndComplianceCenterV3 Integration Tests`, func() {
shouldSkipTest()
})
It(`CreateCustomControlLibrary(createCustomControlLibraryOptions *CreateCustomControlLibraryOptions)`, func() {
assessmentPrototypeModel := &securityandcompliancecenterv3.AssessmentPrototype{
assessmentPrototypeModel := &securityandcompliancecenterv3.Assessment{
AssessmentID: core.StringPtr("rule-d1bd9f3f-bee1-46c5-9533-da8bba9eed4e"),
AssessmentDescription: core.StringPtr("This rule will check on regulation"),
}

controlSpecificationPrototypeModel := &securityandcompliancecenterv3.ControlSpecificationPrototype{
controlSpecificationPrototypeModel := &securityandcompliancecenterv3.ControlSpecification{
ComponentID: core.StringPtr("apprapp"),
Environment: core.StringPtr("ibm-cloud"),
Description: core.StringPtr("This field is used to describe a control specification"),
Assessments: []securityandcompliancecenterv3.AssessmentPrototype{*assessmentPrototypeModel},
Assessments: []securityandcompliancecenterv3.Assessment{*assessmentPrototypeModel},
}

controlDocModel := &securityandcompliancecenterv3.ControlDoc{}

controlPrototypeModel := &securityandcompliancecenterv3.ControlPrototype{
controlPrototypeModel := &securityandcompliancecenterv3.Control{
ControlName: core.StringPtr("security"),
ControlDescription: core.StringPtr("This control library can be deleted"),
ControlCategory: core.StringPtr("test-control"),
ControlRequirement: core.BoolPtr(true),
ControlParent: core.StringPtr(""),
ControlSpecifications: []securityandcompliancecenterv3.ControlSpecificationPrototype{*controlSpecificationPrototypeModel},
ControlSpecifications: []securityandcompliancecenterv3.ControlSpecification{*controlSpecificationPrototypeModel},
ControlDocs: controlDocModel,
Status: core.StringPtr("disabled"),
}
Expand All @@ -298,7 +298,7 @@ var _ = Describe(`SecurityAndComplianceCenterV3 Integration Tests`, func() {
ControlLibraryDescription: core.StringPtr("This is a custom control library made from the SDK test framework"),
ControlLibraryType: core.StringPtr("custom"),
ControlLibraryVersion: core.StringPtr("0.0.1"),
Controls: []securityandcompliancecenterv3.ControlPrototype{*controlPrototypeModel},
Controls: []securityandcompliancecenterv3.Control{*controlPrototypeModel},
AccountID: &accountIDForReportLink,
}

Expand Down
Loading

0 comments on commit 53b424c

Please sign in to comment.