diff --git a/CHANGELOG.md b/CHANGELOG.md index 60d5e6ee8..23ef69e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Add new `elasticstack_elasticsearch_ml_datafeed_state` resource ([#1422](https://github.com/elastic/terraform-provider-elasticstack/pull/1422)) - Add `output_id` to `elasticstack_fleet_integration_policy` resource ([#1445](https://github.com/elastic/terraform-provider-elasticstack/pull/1445)) - Make `hosts` attribute required in `elasticstack_fleet_output` resource ([#1450](https://github.com/elastic/terraform-provider-elasticstack/pull/1450/files)) +- Fix `elasticstack_kibana_security_detection_rule` to properly respect `space_id` ## [0.12.1] - 2025-10-22 - Fix regression restricting the characters in an `elasticstack_elasticsearch_role_mapping` `name`. ([#1373](https://github.com/elastic/terraform-provider-elasticstack/pull/1373)) diff --git a/generated/kbapi/kibana.gen.go b/generated/kbapi/kibana.gen.go index 4a7fa860e..57dd6b0b3 100644 --- a/generated/kbapi/kibana.gen.go +++ b/generated/kbapi/kibana.gen.go @@ -27189,24 +27189,6 @@ type SetDefaultDatailViewDefaultJSONBody struct { Force *bool `json:"force,omitempty"` } -// DeleteRuleParams defines parameters for DeleteRule. -type DeleteRuleParams struct { - // Id The rule's `id` value. - Id *SecurityDetectionsAPIRuleObjectId `form:"id,omitempty" json:"id,omitempty"` - - // RuleId The rule's `rule_id` value. - RuleId *SecurityDetectionsAPIRuleSignatureId `form:"rule_id,omitempty" json:"rule_id,omitempty"` -} - -// ReadRuleParams defines parameters for ReadRule. -type ReadRuleParams struct { - // Id The rule's `id` value. - Id *SecurityDetectionsAPIRuleObjectId `form:"id,omitempty" json:"id,omitempty"` - - // RuleId The rule's `rule_id` value. - RuleId *SecurityDetectionsAPIRuleSignatureId `form:"rule_id,omitempty" json:"rule_id,omitempty"` -} - // PerformRulesBulkActionJSONBody defines parameters for PerformRulesBulkAction. type PerformRulesBulkActionJSONBody struct { union json.RawMessage @@ -46057,6 +46039,24 @@ type PutActionsConnectorIdJSONBody struct { Secrets *UpdateConnectorSecrets `json:"secrets,omitempty"` } +// DeleteRuleParams defines parameters for DeleteRule. +type DeleteRuleParams struct { + // Id The rule's `id` value. + Id *SecurityDetectionsAPIRuleObjectId `form:"id,omitempty" json:"id,omitempty"` + + // RuleId The rule's `rule_id` value. + RuleId *SecurityDetectionsAPIRuleSignatureId `form:"rule_id,omitempty" json:"rule_id,omitempty"` +} + +// ReadRuleParams defines parameters for ReadRule. +type ReadRuleParams struct { + // Id The rule's `id` value. + Id *SecurityDetectionsAPIRuleObjectId `form:"id,omitempty" json:"id,omitempty"` + + // RuleId The rule's `rule_id` value. + RuleId *SecurityDetectionsAPIRuleSignatureId `form:"rule_id,omitempty" json:"rule_id,omitempty"` +} + // PostMaintenanceWindowJSONBody defines parameters for PostMaintenanceWindow. type PostMaintenanceWindowJSONBody struct { // Enabled Whether the current maintenance window is enabled. Disabled maintenance windows do not suppress notifications. @@ -46339,15 +46339,6 @@ type SwapDataViewsDefaultJSONRequestBody = DataViewsSwapDataViewRequestObject // PreviewSwapDataViewsDefaultJSONRequestBody defines body for PreviewSwapDataViewsDefault for application/json ContentType. type PreviewSwapDataViewsDefaultJSONRequestBody = DataViewsSwapDataViewRequestObject -// PatchRuleJSONRequestBody defines body for PatchRule for application/json ContentType. -type PatchRuleJSONRequestBody = SecurityDetectionsAPIRulePatchProps - -// CreateRuleJSONRequestBody defines body for CreateRule for application/json ContentType. -type CreateRuleJSONRequestBody = SecurityDetectionsAPIRuleCreateProps - -// UpdateRuleJSONRequestBody defines body for UpdateRule for application/json ContentType. -type UpdateRuleJSONRequestBody = SecurityDetectionsAPIRuleUpdateProps - // PerformRulesBulkActionJSONRequestBody defines body for PerformRulesBulkAction for application/json ContentType. type PerformRulesBulkActionJSONRequestBody PerformRulesBulkActionJSONBody @@ -46933,6 +46924,15 @@ type CreateDataViewDefaultwJSONRequestBody = DataViewsCreateDataViewRequestObjec // UpdateDataViewDefaultJSONRequestBody defines body for UpdateDataViewDefault for application/json ContentType. type UpdateDataViewDefaultJSONRequestBody = DataViewsUpdateDataViewRequestObject +// PatchRuleJSONRequestBody defines body for PatchRule for application/json ContentType. +type PatchRuleJSONRequestBody = SecurityDetectionsAPIRulePatchProps + +// CreateRuleJSONRequestBody defines body for CreateRule for application/json ContentType. +type CreateRuleJSONRequestBody = SecurityDetectionsAPIRuleCreateProps + +// UpdateRuleJSONRequestBody defines body for UpdateRule for application/json ContentType. +type UpdateRuleJSONRequestBody = SecurityDetectionsAPIRuleUpdateProps + // PostMaintenanceWindowJSONRequestBody defines body for PostMaintenanceWindow for application/json ContentType. type PostMaintenanceWindowJSONRequestBody PostMaintenanceWindowJSONBody @@ -59445,7 +59445,7 @@ func (t SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item) AsSLO // FromSLOsTimesliceMetricBasicMetricWithField overwrites any union data inside the SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item as the provided SLOsTimesliceMetricBasicMetricWithField func (t *SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item) FromSLOsTimesliceMetricBasicMetricWithField(v SLOsTimesliceMetricBasicMetricWithField) error { - v.Aggregation = "max" + v.Aggregation = "avg" b, err := json.Marshal(v) t.union = b return err @@ -59453,7 +59453,7 @@ func (t *SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item) From // MergeSLOsTimesliceMetricBasicMetricWithField performs a merge with any union data inside the SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item, using the provided SLOsTimesliceMetricBasicMetricWithField func (t *SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item) MergeSLOsTimesliceMetricBasicMetricWithField(v SLOsTimesliceMetricBasicMetricWithField) error { - v.Aggregation = "max" + v.Aggregation = "avg" b, err := json.Marshal(v) if err != nil { return err @@ -59534,10 +59534,10 @@ func (t SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item) Value return nil, err } switch discriminator { + case "avg": + return t.AsSLOsTimesliceMetricBasicMetricWithField() case "doc_count": return t.AsSLOsTimesliceMetricDocCountMetric() - case "max": - return t.AsSLOsTimesliceMetricBasicMetricWithField() case "percentile": return t.AsSLOsTimesliceMetricPercentileMetric() default: @@ -73823,27 +73823,6 @@ type ClientInterface interface { // ReadPrivileges request ReadPrivileges(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - // DeleteRule request - DeleteRule(ctx context.Context, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ReadRule request - ReadRule(ctx context.Context, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // PatchRuleWithBody request with any body - PatchRuleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - PatchRule(ctx context.Context, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // CreateRuleWithBody request with any body - CreateRuleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateRule(ctx context.Context, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // UpdateRuleWithBody request with any body - UpdateRuleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - UpdateRule(ctx context.Context, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // PerformRulesBulkActionWithBody request with any body PerformRulesBulkActionWithBody(ctx context.Context, params *PerformRulesBulkActionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -75394,6 +75373,27 @@ type ClientInterface interface { UpdateDataViewDefault(ctx context.Context, spaceId SpaceId, viewId DataViewsViewId, body UpdateDataViewDefaultJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // DeleteRule request + DeleteRule(ctx context.Context, spaceId SpaceId, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReadRule request + ReadRule(ctx context.Context, spaceId SpaceId, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PatchRuleWithBody request with any body + PatchRuleWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PatchRule(ctx context.Context, spaceId SpaceId, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateRuleWithBody request with any body + CreateRuleWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateRule(ctx context.Context, spaceId SpaceId, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateRuleWithBody request with any body + UpdateRuleWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateRule(ctx context.Context, spaceId SpaceId, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostMaintenanceWindowWithBody request with any body PostMaintenanceWindowWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -77200,102 +77200,6 @@ func (c *Client) ReadPrivileges(ctx context.Context, reqEditors ...RequestEditor return c.Client.Do(req) } -func (c *Client) DeleteRule(ctx context.Context, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteRuleRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ReadRule(ctx context.Context, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewReadRuleRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PatchRuleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPatchRuleRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) PatchRule(ctx context.Context, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPatchRuleRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) CreateRuleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateRuleRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) CreateRule(ctx context.Context, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateRuleRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) UpdateRuleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateRuleRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) UpdateRule(ctx context.Context, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateRuleRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - func (c *Client) PerformRulesBulkActionWithBody(ctx context.Context, params *PerformRulesBulkActionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewPerformRulesBulkActionRequestWithBody(c.Server, params, contentType, body) if err != nil { @@ -84244,6 +84148,102 @@ func (c *Client) UpdateDataViewDefault(ctx context.Context, spaceId SpaceId, vie return c.Client.Do(req) } +func (c *Client) DeleteRule(ctx context.Context, spaceId SpaceId, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteRuleRequest(c.Server, spaceId, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ReadRule(ctx context.Context, spaceId SpaceId, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReadRuleRequest(c.Server, spaceId, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PatchRuleWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPatchRuleRequestWithBody(c.Server, spaceId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PatchRule(ctx context.Context, spaceId SpaceId, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPatchRuleRequest(c.Server, spaceId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateRuleWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateRuleRequestWithBody(c.Server, spaceId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateRule(ctx context.Context, spaceId SpaceId, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateRuleRequest(c.Server, spaceId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateRuleWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateRuleRequestWithBody(c.Server, spaceId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateRule(ctx context.Context, spaceId SpaceId, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateRuleRequest(c.Server, spaceId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) PostMaintenanceWindowWithBody(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewPostMaintenanceWindowRequestWithBody(c.Server, spaceId, contentType, body) if err != nil { @@ -89987,256 +89987,6 @@ func NewReadPrivilegesRequest(server string) (*http.Request, error) { return req, nil } -// NewDeleteRuleRequest generates requests for DeleteRule -func NewDeleteRuleRequest(server string, params *DeleteRuleParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/api/detection_engine/rules") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Id != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.RuleId != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "rule_id", runtime.ParamLocationQuery, *params.RuleId); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewReadRuleRequest generates requests for ReadRule -func NewReadRuleRequest(server string, params *ReadRuleParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/api/detection_engine/rules") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Id != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.RuleId != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "rule_id", runtime.ParamLocationQuery, *params.RuleId); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewPatchRuleRequest calls the generic PatchRule builder with application/json body -func NewPatchRuleRequest(server string, body PatchRuleJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPatchRuleRequestWithBody(server, "application/json", bodyReader) -} - -// NewPatchRuleRequestWithBody generates requests for PatchRule with any type of body -func NewPatchRuleRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/api/detection_engine/rules") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PATCH", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewCreateRuleRequest calls the generic CreateRule builder with application/json body -func NewCreateRuleRequest(server string, body CreateRuleJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewCreateRuleRequestWithBody(server, "application/json", bodyReader) -} - -// NewCreateRuleRequestWithBody generates requests for CreateRule with any type of body -func NewCreateRuleRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/api/detection_engine/rules") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewUpdateRuleRequest calls the generic UpdateRule builder with application/json body -func NewUpdateRuleRequest(server string, body UpdateRuleJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewUpdateRuleRequestWithBody(server, "application/json", bodyReader) -} - -// NewUpdateRuleRequestWithBody generates requests for UpdateRule with any type of body -func NewUpdateRuleRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/api/detection_engine/rules") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - // NewPerformRulesBulkActionRequest calls the generic PerformRulesBulkAction builder with application/json body func NewPerformRulesBulkActionRequest(server string, params *PerformRulesBulkActionParams, body PerformRulesBulkActionJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -111069,19 +110819,217 @@ func NewGetDataViewDefaultRequest(server string, spaceId SpaceId, viewId DataVie return req, nil } -// NewUpdateDataViewDefaultRequest calls the generic UpdateDataViewDefault builder with application/json body -func NewUpdateDataViewDefaultRequest(server string, spaceId SpaceId, viewId DataViewsViewId, body UpdateDataViewDefaultJSONRequestBody) (*http.Request, error) { +// NewUpdateDataViewDefaultRequest calls the generic UpdateDataViewDefault builder with application/json body +func NewUpdateDataViewDefaultRequest(server string, spaceId SpaceId, viewId DataViewsViewId, body UpdateDataViewDefaultJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateDataViewDefaultRequestWithBody(server, spaceId, viewId, "application/json", bodyReader) +} + +// NewUpdateDataViewDefaultRequestWithBody generates requests for UpdateDataViewDefault with any type of body +func NewUpdateDataViewDefaultRequestWithBody(server string, spaceId SpaceId, viewId DataViewsViewId, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "viewId", runtime.ParamLocationPath, viewId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/data_views/data_view/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteRuleRequest generates requests for DeleteRule +func NewDeleteRuleRequest(server string, spaceId SpaceId, params *DeleteRuleParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/detection_engine/rules", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Id != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.RuleId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "rule_id", runtime.ParamLocationQuery, *params.RuleId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewReadRuleRequest generates requests for ReadRule +func NewReadRuleRequest(server string, spaceId SpaceId, params *ReadRuleParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/detection_engine/rules", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Id != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.RuleId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "rule_id", runtime.ParamLocationQuery, *params.RuleId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPatchRuleRequest calls the generic PatchRule builder with application/json body +func NewPatchRuleRequest(server string, spaceId SpaceId, body PatchRuleJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewUpdateDataViewDefaultRequestWithBody(server, spaceId, viewId, "application/json", bodyReader) + return NewPatchRuleRequestWithBody(server, spaceId, "application/json", bodyReader) } -// NewUpdateDataViewDefaultRequestWithBody generates requests for UpdateDataViewDefault with any type of body -func NewUpdateDataViewDefaultRequestWithBody(server string, spaceId SpaceId, viewId DataViewsViewId, contentType string, body io.Reader) (*http.Request, error) { +// NewPatchRuleRequestWithBody generates requests for PatchRule with any type of body +func NewPatchRuleRequestWithBody(server string, spaceId SpaceId, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -111091,9 +111039,49 @@ func NewUpdateDataViewDefaultRequestWithBody(server string, spaceId SpaceId, vie return nil, err } - var pathParam1 string + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "viewId", runtime.ParamLocationPath, viewId) + operationPath := fmt.Sprintf("/s/%s/api/detection_engine/rules", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewCreateRuleRequest calls the generic CreateRule builder with application/json body +func NewCreateRuleRequest(server string, spaceId SpaceId, body CreateRuleJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateRuleRequestWithBody(server, spaceId, "application/json", bodyReader) +} + +// NewCreateRuleRequestWithBody generates requests for CreateRule with any type of body +func NewCreateRuleRequestWithBody(server string, spaceId SpaceId, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) if err != nil { return nil, err } @@ -111103,7 +111091,7 @@ func NewUpdateDataViewDefaultRequestWithBody(server string, spaceId SpaceId, vie return nil, err } - operationPath := fmt.Sprintf("/s/%s/api/data_views/data_view/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/s/%s/api/detection_engine/rules", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -111123,6 +111111,53 @@ func NewUpdateDataViewDefaultRequestWithBody(server string, spaceId SpaceId, vie return req, nil } +// NewUpdateRuleRequest calls the generic UpdateRule builder with application/json body +func NewUpdateRuleRequest(server string, spaceId SpaceId, body UpdateRuleJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateRuleRequestWithBody(server, spaceId, "application/json", bodyReader) +} + +// NewUpdateRuleRequestWithBody generates requests for UpdateRule with any type of body +func NewUpdateRuleRequestWithBody(server string, spaceId SpaceId, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/detection_engine/rules", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewPostMaintenanceWindowRequest calls the generic PostMaintenanceWindow builder with application/json body func NewPostMaintenanceWindowRequest(server string, spaceId SpaceId, body PostMaintenanceWindowJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -112558,27 +112593,6 @@ type ClientWithResponsesInterface interface { // ReadPrivilegesWithResponse request ReadPrivilegesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReadPrivilegesResponse, error) - // DeleteRuleWithResponse request - DeleteRuleWithResponse(ctx context.Context, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*DeleteRuleResponse, error) - - // ReadRuleWithResponse request - ReadRuleWithResponse(ctx context.Context, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*ReadRuleResponse, error) - - // PatchRuleWithBodyWithResponse request with any body - PatchRuleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) - - PatchRuleWithResponse(ctx context.Context, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) - - // CreateRuleWithBodyWithResponse request with any body - CreateRuleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) - - CreateRuleWithResponse(ctx context.Context, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) - - // UpdateRuleWithBodyWithResponse request with any body - UpdateRuleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) - - UpdateRuleWithResponse(ctx context.Context, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) - // PerformRulesBulkActionWithBodyWithResponse request with any body PerformRulesBulkActionWithBodyWithResponse(ctx context.Context, params *PerformRulesBulkActionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PerformRulesBulkActionResponse, error) @@ -114129,6 +114143,27 @@ type ClientWithResponsesInterface interface { UpdateDataViewDefaultWithResponse(ctx context.Context, spaceId SpaceId, viewId DataViewsViewId, body UpdateDataViewDefaultJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateDataViewDefaultResponse, error) + // DeleteRuleWithResponse request + DeleteRuleWithResponse(ctx context.Context, spaceId SpaceId, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*DeleteRuleResponse, error) + + // ReadRuleWithResponse request + ReadRuleWithResponse(ctx context.Context, spaceId SpaceId, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*ReadRuleResponse, error) + + // PatchRuleWithBodyWithResponse request with any body + PatchRuleWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) + + PatchRuleWithResponse(ctx context.Context, spaceId SpaceId, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) + + // CreateRuleWithBodyWithResponse request with any body + CreateRuleWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) + + CreateRuleWithResponse(ctx context.Context, spaceId SpaceId, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) + + // UpdateRuleWithBodyWithResponse request with any body + UpdateRuleWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) + + UpdateRuleWithResponse(ctx context.Context, spaceId SpaceId, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) + // PostMaintenanceWindowWithBodyWithResponse request with any body PostMaintenanceWindowWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostMaintenanceWindowResponse, error) @@ -118571,116 +118606,6 @@ func (r ReadPrivilegesResponse) StatusCode() int { return 0 } -type DeleteRuleResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SecurityDetectionsAPIRuleResponse -} - -// Status returns HTTPResponse.Status -func (r DeleteRuleResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteRuleResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type ReadRuleResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SecurityDetectionsAPIRuleResponse -} - -// Status returns HTTPResponse.Status -func (r ReadRuleResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ReadRuleResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type PatchRuleResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SecurityDetectionsAPIRuleResponse -} - -// Status returns HTTPResponse.Status -func (r PatchRuleResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r PatchRuleResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type CreateRuleResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SecurityDetectionsAPIRuleResponse -} - -// Status returns HTTPResponse.Status -func (r CreateRuleResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r CreateRuleResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type UpdateRuleResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *SecurityDetectionsAPIRuleResponse -} - -// Status returns HTTPResponse.Status -func (r UpdateRuleResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateRuleResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - type PerformRulesBulkActionResponse struct { Body []byte HTTPResponse *http.Response @@ -132604,6 +132529,116 @@ func (r UpdateDataViewDefaultResponse) StatusCode() int { return 0 } +type DeleteRuleResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *SecurityDetectionsAPIRuleResponse +} + +// Status returns HTTPResponse.Status +func (r DeleteRuleResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteRuleResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ReadRuleResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *SecurityDetectionsAPIRuleResponse +} + +// Status returns HTTPResponse.Status +func (r ReadRuleResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReadRuleResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PatchRuleResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *SecurityDetectionsAPIRuleResponse +} + +// Status returns HTTPResponse.Status +func (r PatchRuleResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PatchRuleResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CreateRuleResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *SecurityDetectionsAPIRuleResponse +} + +// Status returns HTTPResponse.Status +func (r CreateRuleResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateRuleResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateRuleResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *SecurityDetectionsAPIRuleResponse +} + +// Status returns HTTPResponse.Status +func (r UpdateRuleResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateRuleResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type PostMaintenanceWindowResponse struct { Body []byte HTTPResponse *http.Response @@ -134477,75 +134512,6 @@ func (c *ClientWithResponses) ReadPrivilegesWithResponse(ctx context.Context, re return ParseReadPrivilegesResponse(rsp) } -// DeleteRuleWithResponse request returning *DeleteRuleResponse -func (c *ClientWithResponses) DeleteRuleWithResponse(ctx context.Context, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*DeleteRuleResponse, error) { - rsp, err := c.DeleteRule(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteRuleResponse(rsp) -} - -// ReadRuleWithResponse request returning *ReadRuleResponse -func (c *ClientWithResponses) ReadRuleWithResponse(ctx context.Context, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*ReadRuleResponse, error) { - rsp, err := c.ReadRule(ctx, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseReadRuleResponse(rsp) -} - -// PatchRuleWithBodyWithResponse request with arbitrary body returning *PatchRuleResponse -func (c *ClientWithResponses) PatchRuleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) { - rsp, err := c.PatchRuleWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePatchRuleResponse(rsp) -} - -func (c *ClientWithResponses) PatchRuleWithResponse(ctx context.Context, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) { - rsp, err := c.PatchRule(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParsePatchRuleResponse(rsp) -} - -// CreateRuleWithBodyWithResponse request with arbitrary body returning *CreateRuleResponse -func (c *ClientWithResponses) CreateRuleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) { - rsp, err := c.CreateRuleWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateRuleResponse(rsp) -} - -func (c *ClientWithResponses) CreateRuleWithResponse(ctx context.Context, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) { - rsp, err := c.CreateRule(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateRuleResponse(rsp) -} - -// UpdateRuleWithBodyWithResponse request with arbitrary body returning *UpdateRuleResponse -func (c *ClientWithResponses) UpdateRuleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) { - rsp, err := c.UpdateRuleWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateRuleResponse(rsp) -} - -func (c *ClientWithResponses) UpdateRuleWithResponse(ctx context.Context, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) { - rsp, err := c.UpdateRule(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateRuleResponse(rsp) -} - // PerformRulesBulkActionWithBodyWithResponse request with arbitrary body returning *PerformRulesBulkActionResponse func (c *ClientWithResponses) PerformRulesBulkActionWithBodyWithResponse(ctx context.Context, params *PerformRulesBulkActionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PerformRulesBulkActionResponse, error) { rsp, err := c.PerformRulesBulkActionWithBody(ctx, params, contentType, body, reqEditors...) @@ -139570,6 +139536,75 @@ func (c *ClientWithResponses) UpdateDataViewDefaultWithResponse(ctx context.Cont return ParseUpdateDataViewDefaultResponse(rsp) } +// DeleteRuleWithResponse request returning *DeleteRuleResponse +func (c *ClientWithResponses) DeleteRuleWithResponse(ctx context.Context, spaceId SpaceId, params *DeleteRuleParams, reqEditors ...RequestEditorFn) (*DeleteRuleResponse, error) { + rsp, err := c.DeleteRule(ctx, spaceId, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteRuleResponse(rsp) +} + +// ReadRuleWithResponse request returning *ReadRuleResponse +func (c *ClientWithResponses) ReadRuleWithResponse(ctx context.Context, spaceId SpaceId, params *ReadRuleParams, reqEditors ...RequestEditorFn) (*ReadRuleResponse, error) { + rsp, err := c.ReadRule(ctx, spaceId, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseReadRuleResponse(rsp) +} + +// PatchRuleWithBodyWithResponse request with arbitrary body returning *PatchRuleResponse +func (c *ClientWithResponses) PatchRuleWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) { + rsp, err := c.PatchRuleWithBody(ctx, spaceId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePatchRuleResponse(rsp) +} + +func (c *ClientWithResponses) PatchRuleWithResponse(ctx context.Context, spaceId SpaceId, body PatchRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*PatchRuleResponse, error) { + rsp, err := c.PatchRule(ctx, spaceId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePatchRuleResponse(rsp) +} + +// CreateRuleWithBodyWithResponse request with arbitrary body returning *CreateRuleResponse +func (c *ClientWithResponses) CreateRuleWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) { + rsp, err := c.CreateRuleWithBody(ctx, spaceId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateRuleResponse(rsp) +} + +func (c *ClientWithResponses) CreateRuleWithResponse(ctx context.Context, spaceId SpaceId, body CreateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRuleResponse, error) { + rsp, err := c.CreateRule(ctx, spaceId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateRuleResponse(rsp) +} + +// UpdateRuleWithBodyWithResponse request with arbitrary body returning *UpdateRuleResponse +func (c *ClientWithResponses) UpdateRuleWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) { + rsp, err := c.UpdateRuleWithBody(ctx, spaceId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateRuleResponse(rsp) +} + +func (c *ClientWithResponses) UpdateRuleWithResponse(ctx context.Context, spaceId SpaceId, body UpdateRuleJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateRuleResponse, error) { + rsp, err := c.UpdateRule(ctx, spaceId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateRuleResponse(rsp) +} + // PostMaintenanceWindowWithBodyWithResponse request with arbitrary body returning *PostMaintenanceWindowResponse func (c *ClientWithResponses) PostMaintenanceWindowWithBodyWithResponse(ctx context.Context, spaceId SpaceId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostMaintenanceWindowResponse, error) { rsp, err := c.PostMaintenanceWindowWithBody(ctx, spaceId, contentType, body, reqEditors...) @@ -144846,136 +144881,6 @@ func ParseReadPrivilegesResponse(rsp *http.Response) (*ReadPrivilegesResponse, e return response, nil } -// ParseDeleteRuleResponse parses an HTTP response from a DeleteRuleWithResponse call -func ParseDeleteRuleResponse(rsp *http.Response) (*DeleteRuleResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &DeleteRuleResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SecurityDetectionsAPIRuleResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - } - - return response, nil -} - -// ParseReadRuleResponse parses an HTTP response from a ReadRuleWithResponse call -func ParseReadRuleResponse(rsp *http.Response) (*ReadRuleResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ReadRuleResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SecurityDetectionsAPIRuleResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - } - - return response, nil -} - -// ParsePatchRuleResponse parses an HTTP response from a PatchRuleWithResponse call -func ParsePatchRuleResponse(rsp *http.Response) (*PatchRuleResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &PatchRuleResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SecurityDetectionsAPIRuleResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - } - - return response, nil -} - -// ParseCreateRuleResponse parses an HTTP response from a CreateRuleWithResponse call -func ParseCreateRuleResponse(rsp *http.Response) (*CreateRuleResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &CreateRuleResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SecurityDetectionsAPIRuleResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - } - - return response, nil -} - -// ParseUpdateRuleResponse parses an HTTP response from a UpdateRuleWithResponse call -func ParseUpdateRuleResponse(rsp *http.Response) (*UpdateRuleResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &UpdateRuleResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SecurityDetectionsAPIRuleResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - } - - return response, nil -} - // ParsePerformRulesBulkActionResponse parses an HTTP response from a PerformRulesBulkActionWithResponse call func ParsePerformRulesBulkActionResponse(rsp *http.Response) (*PerformRulesBulkActionResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -160634,6 +160539,136 @@ func ParseUpdateDataViewDefaultResponse(rsp *http.Response) (*UpdateDataViewDefa return response, nil } +// ParseDeleteRuleResponse parses an HTTP response from a DeleteRuleWithResponse call +func ParseDeleteRuleResponse(rsp *http.Response) (*DeleteRuleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteRuleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SecurityDetectionsAPIRuleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseReadRuleResponse parses an HTTP response from a ReadRuleWithResponse call +func ParseReadRuleResponse(rsp *http.Response) (*ReadRuleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReadRuleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SecurityDetectionsAPIRuleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePatchRuleResponse parses an HTTP response from a PatchRuleWithResponse call +func ParsePatchRuleResponse(rsp *http.Response) (*PatchRuleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PatchRuleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SecurityDetectionsAPIRuleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseCreateRuleResponse parses an HTTP response from a CreateRuleWithResponse call +func ParseCreateRuleResponse(rsp *http.Response) (*CreateRuleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateRuleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SecurityDetectionsAPIRuleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseUpdateRuleResponse parses an HTTP response from a UpdateRuleWithResponse call +func ParseUpdateRuleResponse(rsp *http.Response) (*UpdateRuleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateRuleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SecurityDetectionsAPIRuleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParsePostMaintenanceWindowResponse parses an HTTP response from a PostMaintenanceWindowWithResponse call func ParsePostMaintenanceWindowResponse(rsp *http.Response) (*PostMaintenanceWindowResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/generated/kbapi/transform_schema.go b/generated/kbapi/transform_schema.go index 962151838..a377cfe9b 100644 --- a/generated/kbapi/transform_schema.go +++ b/generated/kbapi/transform_schema.go @@ -690,6 +690,7 @@ func transformKibanaPaths(schema *Schema) { "/api/maintenance_window/{id}", "/api/actions/connector/{id}", "/api/actions/connectors", + "/api/detection_engine/rules", } // Add a spaceId parameter if not already present diff --git a/internal/kibana/security_detection_rule/acc_test.go b/internal/kibana/security_detection_rule/acc_test.go index 546fb8726..2e8515e35 100644 --- a/internal/kibana/security_detection_rule/acc_test.go +++ b/internal/kibana/security_detection_rule/acc_test.go @@ -243,6 +243,12 @@ func TestAccResourceSecurityDetectionRule_Query(t *testing.T) { resource.TestCheckNoResourceAttr(resourceName, "filters"), ), }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minResponseActionVersionSupport), + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -1367,7 +1373,7 @@ func testAccCheckSecurityDetectionRuleDestroy(s *terraform.State) error { Id: &ruleObjectId, } - response, err := kbClient.API.ReadRuleWithResponse(context.Background(), params) + response, err := kbClient.API.ReadRuleWithResponse(context.Background(), parts[0], params) if err != nil { return fmt.Errorf("failed to read security detection rule: %v", err) } @@ -3694,6 +3700,113 @@ resource "elasticstack_kibana_security_detection_rule" "test" { `, name) } +func TestAccResourceSecurityDetectionRule_QueryMinimalWithSpace(t *testing.T) { + resourceName := "elasticstack_kibana_security_detection_rule.test" + spaceResourceName := "elasticstack_kibana_space.test" + spaceID := fmt.Sprintf("test-space-%s", uuid.New().String()[:8]) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ProtoV6ProviderFactories: acctest.Providers, + CheckDestroy: testAccCheckSecurityDetectionRuleDestroy, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionSupport), + Config: testAccSecurityDetectionRuleConfig_queryMinimalWithSpace("test-query-rule-with-space", spaceID), + Check: resource.ComposeTestCheckFunc( + // Check space attributes + resource.TestCheckResourceAttr(spaceResourceName, "space_id", spaceID), + resource.TestCheckResourceAttr(spaceResourceName, "name", "Test Space for Detection Rules"), + + // Check detection rule attributes + resource.TestCheckResourceAttr(resourceName, "name", "test-query-rule-with-space"), + resource.TestCheckResourceAttr(resourceName, "type", "query"), + resource.TestCheckResourceAttr(resourceName, "query", "*:*"), + resource.TestCheckResourceAttr(resourceName, "language", "kuery"), + resource.TestCheckResourceAttr(resourceName, "enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "description", "Minimal test query security detection rule in custom space"), + resource.TestCheckResourceAttr(resourceName, "severity", "low"), + resource.TestCheckResourceAttr(resourceName, "risk_score", "21"), + resource.TestCheckResourceAttr(resourceName, "index.0", "logs-*"), + resource.TestCheckResourceAttr(resourceName, "space_id", spaceID), + + // Verify required fields are set + resource.TestCheckResourceAttrSet(resourceName, "id"), + resource.TestCheckResourceAttrSet(resourceName, "rule_id"), + resource.TestCheckResourceAttrSet(resourceName, "created_at"), + resource.TestCheckResourceAttrSet(resourceName, "created_by"), + + // Verify optional fields are not set + resource.TestCheckNoResourceAttr(resourceName, "data_view_id"), + resource.TestCheckNoResourceAttr(resourceName, "namespace"), + resource.TestCheckNoResourceAttr(resourceName, "rule_name_override"), + resource.TestCheckNoResourceAttr(resourceName, "timestamp_override"), + resource.TestCheckNoResourceAttr(resourceName, "timestamp_override_fallback_disabled"), + resource.TestCheckNoResourceAttr(resourceName, "filters"), + resource.TestCheckNoResourceAttr(resourceName, "investigation_fields"), + resource.TestCheckNoResourceAttr(resourceName, "risk_score_mapping"), + resource.TestCheckNoResourceAttr(resourceName, "related_integrations"), + resource.TestCheckNoResourceAttr(resourceName, "required_fields"), + resource.TestCheckNoResourceAttr(resourceName, "severity_mapping"), + resource.TestCheckNoResourceAttr(resourceName, "response_actions"), + resource.TestCheckNoResourceAttr(resourceName, "alert_suppression"), + resource.TestCheckNoResourceAttr(resourceName, "building_block_type"), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionSupport), + Config: testAccSecurityDetectionRuleConfig_queryMinimalWithSpaceUpdate("test-query-rule-with-space-updated", spaceID), + Check: resource.ComposeTestCheckFunc( + // Check space attributes remain the same + resource.TestCheckResourceAttr(spaceResourceName, "space_id", spaceID), + resource.TestCheckResourceAttr(spaceResourceName, "name", "Test Space for Detection Rules"), + + // Check updated detection rule attributes + resource.TestCheckResourceAttr(resourceName, "name", "test-query-rule-with-space-updated"), + resource.TestCheckResourceAttr(resourceName, "type", "query"), + resource.TestCheckResourceAttr(resourceName, "query", "event.category:authentication"), + resource.TestCheckResourceAttr(resourceName, "language", "kuery"), + resource.TestCheckResourceAttr(resourceName, "enabled", "false"), + resource.TestCheckResourceAttr(resourceName, "description", "Updated minimal test query security detection rule in custom space"), + resource.TestCheckResourceAttr(resourceName, "severity", "medium"), + resource.TestCheckResourceAttr(resourceName, "risk_score", "55"), + resource.TestCheckResourceAttr(resourceName, "index.0", "logs-*"), + resource.TestCheckResourceAttr(resourceName, "index.1", "winlogbeat-*"), + resource.TestCheckResourceAttr(resourceName, "space_id", spaceID), + + // Verify required fields are still set + resource.TestCheckResourceAttrSet(resourceName, "id"), + resource.TestCheckResourceAttrSet(resourceName, "rule_id"), + resource.TestCheckResourceAttrSet(resourceName, "created_at"), + resource.TestCheckResourceAttrSet(resourceName, "created_by"), + + // Verify optional fields are still not set + resource.TestCheckNoResourceAttr(resourceName, "data_view_id"), + resource.TestCheckNoResourceAttr(resourceName, "namespace"), + resource.TestCheckNoResourceAttr(resourceName, "rule_name_override"), + resource.TestCheckNoResourceAttr(resourceName, "timestamp_override"), + resource.TestCheckNoResourceAttr(resourceName, "timestamp_override_fallback_disabled"), + resource.TestCheckNoResourceAttr(resourceName, "filters"), + resource.TestCheckNoResourceAttr(resourceName, "investigation_fields"), + resource.TestCheckNoResourceAttr(resourceName, "risk_score_mapping"), + resource.TestCheckNoResourceAttr(resourceName, "related_integrations"), + resource.TestCheckNoResourceAttr(resourceName, "required_fields"), + resource.TestCheckNoResourceAttr(resourceName, "severity_mapping"), + resource.TestCheckNoResourceAttr(resourceName, "response_actions"), + resource.TestCheckNoResourceAttr(resourceName, "alert_suppression"), + resource.TestCheckNoResourceAttr(resourceName, "building_block_type"), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionSupport), + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccResourceSecurityDetectionRule_EQLMinimal(t *testing.T) { resourceName := "elasticstack_kibana_security_detection_rule.test" @@ -4625,6 +4738,66 @@ func TestAccResourceSecurityDetectionRule_QueryWithMitreThreat(t *testing.T) { }) } +func testAccSecurityDetectionRuleConfig_queryMinimalWithSpace(name, spaceID string) string { + return fmt.Sprintf(` +provider "elasticstack" { + kibana {} +} + +resource "elasticstack_kibana_space" "test" { + space_id = "%s" + name = "Test Space for Detection Rules" + description = "Space for testing detection rules" +} + +resource "elasticstack_kibana_security_detection_rule" "test" { + space_id = elasticstack_kibana_space.test.space_id + name = "%s" + type = "query" + query = "*:*" + language = "kuery" + enabled = true + description = "Minimal test query security detection rule in custom space" + severity = "low" + risk_score = 21 + from = "now-6m" + to = "now" + interval = "5m" + index = ["logs-*"] +} +`, spaceID, name) +} + +func testAccSecurityDetectionRuleConfig_queryMinimalWithSpaceUpdate(name, spaceID string) string { + return fmt.Sprintf(` +provider "elasticstack" { + kibana {} +} + +resource "elasticstack_kibana_space" "test" { + space_id = "%s" + name = "Test Space for Detection Rules" + description = "Space for testing detection rules" +} + +resource "elasticstack_kibana_security_detection_rule" "test" { + space_id = elasticstack_kibana_space.test.space_id + name = "%s" + type = "query" + query = "event.category:authentication" + language = "kuery" + enabled = false + description = "Updated minimal test query security detection rule in custom space" + severity = "medium" + risk_score = 55 + from = "now-12m" + to = "now" + interval = "10m" + index = ["logs-*", "winlogbeat-*"] +} +`, spaceID, name) +} + func testAccSecurityDetectionRuleConfig_queryWithMitreThreat(name string) string { return fmt.Sprintf(` provider "elasticstack" { diff --git a/internal/kibana/security_detection_rule/create.go b/internal/kibana/security_detection_rule/create.go index 7a0e0e6ee..fd86f43ab 100644 --- a/internal/kibana/security_detection_rule/create.go +++ b/internal/kibana/security_detection_rule/create.go @@ -35,7 +35,7 @@ func (r *securityDetectionRuleResource) Create(ctx context.Context, req resource } // Create the rule - response, err := kbClient.API.CreateRuleWithResponse(ctx, createProps) + response, err := kbClient.API.CreateRuleWithResponse(ctx, data.SpaceId.ValueString(), createProps) if err != nil { resp.Diagnostics.AddError( "Error creating security detection rule", diff --git a/internal/kibana/security_detection_rule/delete.go b/internal/kibana/security_detection_rule/delete.go index d2e1a48bb..2143a0676 100644 --- a/internal/kibana/security_detection_rule/delete.go +++ b/internal/kibana/security_detection_rule/delete.go @@ -46,7 +46,7 @@ func (r *securityDetectionRuleResource) Delete(ctx context.Context, req resource Id: &ruleObjectId, } - response, err := kbClient.API.DeleteRuleWithResponse(ctx, params) + response, err := kbClient.API.DeleteRuleWithResponse(ctx, data.SpaceId.ValueString(), params) if err != nil { resp.Diagnostics.AddError( "Error deleting security detection rule", diff --git a/internal/kibana/security_detection_rule/read.go b/internal/kibana/security_detection_rule/read.go index e0b86bd1b..5894dc7e7 100644 --- a/internal/kibana/security_detection_rule/read.go +++ b/internal/kibana/security_detection_rule/read.go @@ -74,7 +74,7 @@ func (r *securityDetectionRuleResource) read(ctx context.Context, resourceId, sp Id: &ruleObjectId, } - response, err := kbClient.API.ReadRuleWithResponse(ctx, params) + response, err := kbClient.API.ReadRuleWithResponse(ctx, spaceId, params) if err != nil { diags.AddError( "Error reading security detection rule", diff --git a/internal/kibana/security_detection_rule/update.go b/internal/kibana/security_detection_rule/update.go index 50ea9feb4..3fa005e26 100644 --- a/internal/kibana/security_detection_rule/update.go +++ b/internal/kibana/security_detection_rule/update.go @@ -35,7 +35,7 @@ func (r *securityDetectionRuleResource) Update(ctx context.Context, req resource } // Update the rule - response, err := kbClient.API.UpdateRuleWithResponse(ctx, updateProps) + response, err := kbClient.API.UpdateRuleWithResponse(ctx, data.SpaceId.ValueString(), updateProps) if err != nil { resp.Diagnostics.AddError( "Error updating security detection rule",