From b7eee2ba96906b5e74489f976b2c7cdd2321df9e Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 20 Dec 2022 16:46:23 +0000 Subject: [PATCH] Regenerate client from commit ec3c91a9 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 10 ++- ...d_configuration_compliance_rule_options.go | 83 +++++++++---------- .../model_cloud_configuration_rule_options.go | 2 + .../model_security_monitoring_rule_options.go | 2 + ...CreateSecurityMonitoringRule_1092490364.go | 4 +- .../UpdateSecurityMonitoringRule_428087276.go | 4 +- 7 files changed, 59 insertions(+), 54 deletions(-) diff --git a/.apigentools-info b/.apigentools-info index 89aaef1b61f..3023740da0f 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2022-12-19 15:44:02.177148", - "spec_repo_commit": "37d94b14" + "regenerated": "2022-12-20 16:44:27.418644", + "spec_repo_commit": "ec3c91a9" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2022-12-19 15:44:02.188913", - "spec_repo_commit": "37d94b14" + "regenerated": "2022-12-20 16:44:27.430114", + "spec_repo_commit": "ec3c91a9" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index eee4d46c5d2..fb4e260e6fe 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1776,7 +1776,12 @@ components: type: string type: object CloudConfigurationComplianceRuleOptions: - description: Options for cloud_configuration rules. + description: 'Options for cloud_configuration rules. + + Fields `resourceType` and `regoRule` are mandatory when managing custom `cloud_configuration` + rules. + + ' properties: complexRule: description: 'Whether the rule is a complex one. @@ -1795,9 +1800,6 @@ components: ' example: aws_acm type: string - required: - - resourceType - - regoRule type: object CloudConfigurationRegoRule: description: Rule details. diff --git a/api/datadogV2/model_cloud_configuration_compliance_rule_options.go b/api/datadogV2/model_cloud_configuration_compliance_rule_options.go index 44236bb3f2b..ee764ce4ddc 100644 --- a/api/datadogV2/model_cloud_configuration_compliance_rule_options.go +++ b/api/datadogV2/model_cloud_configuration_compliance_rule_options.go @@ -6,20 +6,21 @@ package datadogV2 import ( "encoding/json" - "fmt" ) // CloudConfigurationComplianceRuleOptions Options for cloud_configuration rules. +// Fields `resourceType` and `regoRule` are mandatory when managing custom `cloud_configuration` rules. +// type CloudConfigurationComplianceRuleOptions struct { // Whether the rule is a complex one. // Must be set to true if `regoRule.resourceTypes` contains more than one item. Defaults to false. // ComplexRule *bool `json:"complexRule,omitempty"` // Rule details. - RegoRule CloudConfigurationRegoRule `json:"regoRule"` + RegoRule *CloudConfigurationRegoRule `json:"regoRule,omitempty"` // Main resource type to be checked by the rule. It should be specified again in `regoRule.resourceTypes`. // - ResourceType string `json:"resourceType"` + ResourceType *string `json:"resourceType,omitempty"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject map[string]interface{} `json:"-"` AdditionalProperties map[string]interface{} @@ -29,10 +30,8 @@ type CloudConfigurationComplianceRuleOptions struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed. -func NewCloudConfigurationComplianceRuleOptions(regoRule CloudConfigurationRegoRule, resourceType string) *CloudConfigurationComplianceRuleOptions { +func NewCloudConfigurationComplianceRuleOptions() *CloudConfigurationComplianceRuleOptions { this := CloudConfigurationComplianceRuleOptions{} - this.RegoRule = regoRule - this.ResourceType = resourceType return &this } @@ -72,50 +71,60 @@ func (o *CloudConfigurationComplianceRuleOptions) SetComplexRule(v bool) { o.ComplexRule = &v } -// GetRegoRule returns the RegoRule field value. +// GetRegoRule returns the RegoRule field value if set, zero value otherwise. func (o *CloudConfigurationComplianceRuleOptions) GetRegoRule() CloudConfigurationRegoRule { - if o == nil { + if o == nil || o.RegoRule == nil { var ret CloudConfigurationRegoRule return ret } - return o.RegoRule + return *o.RegoRule } -// GetRegoRuleOk returns a tuple with the RegoRule field value +// GetRegoRuleOk returns a tuple with the RegoRule field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *CloudConfigurationComplianceRuleOptions) GetRegoRuleOk() (*CloudConfigurationRegoRule, bool) { - if o == nil { + if o == nil || o.RegoRule == nil { return nil, false } - return &o.RegoRule, true + return o.RegoRule, true } -// SetRegoRule sets field value. +// HasRegoRule returns a boolean if a field has been set. +func (o *CloudConfigurationComplianceRuleOptions) HasRegoRule() bool { + return o != nil && o.RegoRule != nil +} + +// SetRegoRule gets a reference to the given CloudConfigurationRegoRule and assigns it to the RegoRule field. func (o *CloudConfigurationComplianceRuleOptions) SetRegoRule(v CloudConfigurationRegoRule) { - o.RegoRule = v + o.RegoRule = &v } -// GetResourceType returns the ResourceType field value. +// GetResourceType returns the ResourceType field value if set, zero value otherwise. func (o *CloudConfigurationComplianceRuleOptions) GetResourceType() string { - if o == nil { + if o == nil || o.ResourceType == nil { var ret string return ret } - return o.ResourceType + return *o.ResourceType } -// GetResourceTypeOk returns a tuple with the ResourceType field value +// GetResourceTypeOk returns a tuple with the ResourceType field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *CloudConfigurationComplianceRuleOptions) GetResourceTypeOk() (*string, bool) { - if o == nil { + if o == nil || o.ResourceType == nil { return nil, false } - return &o.ResourceType, true + return o.ResourceType, true +} + +// HasResourceType returns a boolean if a field has been set. +func (o *CloudConfigurationComplianceRuleOptions) HasResourceType() bool { + return o != nil && o.ResourceType != nil } -// SetResourceType sets field value. +// SetResourceType gets a reference to the given string and assigns it to the ResourceType field. func (o *CloudConfigurationComplianceRuleOptions) SetResourceType(v string) { - o.ResourceType = v + o.ResourceType = &v } // MarshalJSON serializes the struct using spec logic. @@ -127,8 +136,12 @@ func (o CloudConfigurationComplianceRuleOptions) MarshalJSON() ([]byte, error) { if o.ComplexRule != nil { toSerialize["complexRule"] = o.ComplexRule } - toSerialize["regoRule"] = o.RegoRule - toSerialize["resourceType"] = o.ResourceType + if o.RegoRule != nil { + toSerialize["regoRule"] = o.RegoRule + } + if o.ResourceType != nil { + toSerialize["resourceType"] = o.ResourceType + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -139,25 +152,11 @@ func (o CloudConfigurationComplianceRuleOptions) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *CloudConfigurationComplianceRuleOptions) UnmarshalJSON(bytes []byte) (err error) { raw := map[string]interface{}{} - required := struct { - RegoRule *CloudConfigurationRegoRule `json:"regoRule"` - ResourceType *string `json:"resourceType"` - }{} all := struct { - ComplexRule *bool `json:"complexRule,omitempty"` - RegoRule CloudConfigurationRegoRule `json:"regoRule"` - ResourceType string `json:"resourceType"` + ComplexRule *bool `json:"complexRule,omitempty"` + RegoRule *CloudConfigurationRegoRule `json:"regoRule,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` }{} - err = json.Unmarshal(bytes, &required) - if err != nil { - return err - } - if required.RegoRule == nil { - return fmt.Errorf("required field regoRule missing") - } - if required.ResourceType == nil { - return fmt.Errorf("required field resourceType missing") - } err = json.Unmarshal(bytes, &all) if err != nil { err = json.Unmarshal(bytes, &raw) @@ -168,7 +167,7 @@ func (o *CloudConfigurationComplianceRuleOptions) UnmarshalJSON(bytes []byte) (e return nil } o.ComplexRule = all.ComplexRule - if all.RegoRule.UnparsedObject != nil && o.UnparsedObject == nil { + if all.RegoRule != nil && all.RegoRule.UnparsedObject != nil && o.UnparsedObject == nil { err = json.Unmarshal(bytes, &raw) if err != nil { return err diff --git a/api/datadogV2/model_cloud_configuration_rule_options.go b/api/datadogV2/model_cloud_configuration_rule_options.go index c63f4e39cd4..e79166813ee 100644 --- a/api/datadogV2/model_cloud_configuration_rule_options.go +++ b/api/datadogV2/model_cloud_configuration_rule_options.go @@ -12,6 +12,8 @@ import ( // CloudConfigurationRuleOptions Options on cloud configuration rules. type CloudConfigurationRuleOptions struct { // Options for cloud_configuration rules. + // Fields `resourceType` and `regoRule` are mandatory when managing custom `cloud_configuration` rules. + // ComplianceRuleOptions CloudConfigurationComplianceRuleOptions `json:"complianceRuleOptions"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject map[string]interface{} `json:"-"` diff --git a/api/datadogV2/model_security_monitoring_rule_options.go b/api/datadogV2/model_security_monitoring_rule_options.go index a2f2aa98345..e06ef9dcbfc 100644 --- a/api/datadogV2/model_security_monitoring_rule_options.go +++ b/api/datadogV2/model_security_monitoring_rule_options.go @@ -11,6 +11,8 @@ import ( // SecurityMonitoringRuleOptions Options on rules. type SecurityMonitoringRuleOptions struct { // Options for cloud_configuration rules. + // Fields `resourceType` and `regoRule` are mandatory when managing custom `cloud_configuration` rules. + // ComplianceRuleOptions *CloudConfigurationComplianceRuleOptions `json:"complianceRuleOptions,omitempty"` // If true, signals in non-production environments have a lower severity than what is defined by the rule case, which can reduce signal noise. // The severity is decreased by one level: `CRITICAL` in production becomes `HIGH` in non-production, `HIGH` becomes `MEDIUM` and so on. `INFO` remains `INFO`. diff --git a/examples/v2/security-monitoring/CreateSecurityMonitoringRule_1092490364.go b/examples/v2/security-monitoring/CreateSecurityMonitoringRule_1092490364.go index 78050df65e7..49f08bdf471 100644 --- a/examples/v2/security-monitoring/CreateSecurityMonitoringRule_1092490364.go +++ b/examples/v2/security-monitoring/CreateSecurityMonitoringRule_1092490364.go @@ -28,9 +28,9 @@ func main() { }, Options: datadogV2.CloudConfigurationRuleOptions{ ComplianceRuleOptions: datadogV2.CloudConfigurationComplianceRuleOptions{ - ResourceType: "gcp_compute_disk", + ResourceType: datadog.PtrString("gcp_compute_disk"), ComplexRule: datadog.PtrBool(false), - RegoRule: datadogV2.CloudConfigurationRegoRule{ + RegoRule: &datadogV2.CloudConfigurationRegoRule{ Policy: `package datadog `, ResourceTypes: []string{ diff --git a/examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.go b/examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.go index e870e9944dd..9ab5fad1af8 100644 --- a/examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.go +++ b/examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.go @@ -27,8 +27,8 @@ func main() { }, Options: &datadogV2.SecurityMonitoringRuleOptions{ ComplianceRuleOptions: &datadogV2.CloudConfigurationComplianceRuleOptions{ - ResourceType: "gcp_compute_disk", - RegoRule: datadogV2.CloudConfigurationRegoRule{ + ResourceType: datadog.PtrString("gcp_compute_disk"), + RegoRule: &datadogV2.CloudConfigurationRegoRule{ Policy: `package datadog `, ResourceTypes: []string{