diff --git a/docs/resources/fleet_integration_policy.md b/docs/resources/fleet_integration_policy.md index f8cd606a8..a8c752f58 100644 --- a/docs/resources/fleet_integration_policy.md +++ b/docs/resources/fleet_integration_policy.md @@ -90,7 +90,6 @@ resource "elasticstack_fleet_integration_policy" "sample" { ### Required -- `agent_policy_id` (String) ID of the agent policy. - `integration_name` (String) The name of the integration package. - `integration_version` (String) The version of the integration package. - `name` (String) The name of the integration policy. @@ -98,6 +97,8 @@ resource "elasticstack_fleet_integration_policy" "sample" { ### Optional +- `agent_policy_id` (String, Deprecated) ID of the agent policy. +- `agent_policy_ids` (List of String) List of agent policy IDs. - `description` (String) The description of the integration policy. - `enabled` (Boolean) Enable the integration policy. - `force` (Boolean) Force operations, such as creation and deletion, to occur. diff --git a/generated/kbapi/kibana.gen.go b/generated/kbapi/kibana.gen.go index 3c947f747..75bf8c708 100644 --- a/generated/kbapi/kibana.gen.go +++ b/generated/kbapi/kibana.gen.go @@ -3212,6 +3212,13 @@ const ( PostFleetAgentsAgentidRequestDiagnosticsJSONBodyAdditionalMetricsCPU PostFleetAgentsAgentidRequestDiagnosticsJSONBodyAdditionalMetrics = "CPU" ) +// Defines values for PostFleetCloudConnectorsJSONBodyCloudProvider. +const ( + Aws PostFleetCloudConnectorsJSONBodyCloudProvider = "aws" + Azure PostFleetCloudConnectorsJSONBodyCloudProvider = "azure" + Gcp PostFleetCloudConnectorsJSONBodyCloudProvider = "gcp" +) + // Defines values for PostFleetEpmCustomIntegrationsJSONBodyDatasetsType. const ( PostFleetEpmCustomIntegrationsJSONBodyDatasetsTypeLogs PostFleetEpmCustomIntegrationsJSONBodyDatasetsType = "logs" @@ -3423,6 +3430,11 @@ const ( PutStreamsNameJSONBody00StreamIngestProcessingSteps06ActionManualIngestPipeline PutStreamsNameJSONBody00StreamIngestProcessingSteps06Action = "manual_ingest_pipeline" ) +// Defines values for PutStreamsNameJSONBody00StreamIngestSettingsIndexRefreshIntervalValue1. +const ( + PutStreamsNameJSONBody00StreamIngestSettingsIndexRefreshIntervalValue1Minus1 PutStreamsNameJSONBody00StreamIngestSettingsIndexRefreshIntervalValue1 = -1 +) + // Defines values for PutStreamsNameJSONBody01StreamIngestProcessingSteps00Action. const ( PutStreamsNameJSONBody01StreamIngestProcessingSteps00ActionGrok PutStreamsNameJSONBody01StreamIngestProcessingSteps00Action = "grok" @@ -3458,6 +3470,11 @@ const ( PutStreamsNameJSONBody01StreamIngestProcessingSteps06ActionManualIngestPipeline PutStreamsNameJSONBody01StreamIngestProcessingSteps06Action = "manual_ingest_pipeline" ) +// Defines values for PutStreamsNameJSONBody01StreamIngestSettingsIndexRefreshIntervalValue1. +const ( + PutStreamsNameJSONBody01StreamIngestSettingsIndexRefreshIntervalValue1Minus1 PutStreamsNameJSONBody01StreamIngestSettingsIndexRefreshIntervalValue1 = -1 +) + // Defines values for PostStreamsNameForkJSONBodyStatus. const ( PostStreamsNameForkJSONBodyStatusDisabled PostStreamsNameForkJSONBodyStatus = "disabled" @@ -3499,6 +3516,11 @@ const ( PutStreamsNameIngestJSONBodyIngest0ProcessingSteps06ActionManualIngestPipeline PutStreamsNameIngestJSONBodyIngest0ProcessingSteps06Action = "manual_ingest_pipeline" ) +// Defines values for PutStreamsNameIngestJSONBodyIngest0SettingsIndexRefreshIntervalValue1. +const ( + PutStreamsNameIngestJSONBodyIngest0SettingsIndexRefreshIntervalValue1Minus1 PutStreamsNameIngestJSONBodyIngest0SettingsIndexRefreshIntervalValue1 = -1 +) + // Defines values for PutStreamsNameIngestJSONBodyIngest0WiredRoutingStatus. const ( PutStreamsNameIngestJSONBodyIngest0WiredRoutingStatusDisabled PutStreamsNameIngestJSONBodyIngest0WiredRoutingStatus = "disabled" @@ -3540,6 +3562,11 @@ const ( PutStreamsNameIngestJSONBodyIngest1ProcessingSteps06ActionManualIngestPipeline PutStreamsNameIngestJSONBodyIngest1ProcessingSteps06Action = "manual_ingest_pipeline" ) +// Defines values for PutStreamsNameIngestJSONBodyIngest1SettingsIndexRefreshIntervalValue1. +const ( + PutStreamsNameIngestJSONBodyIngest1SettingsIndexRefreshIntervalValue1Minus1 PutStreamsNameIngestJSONBodyIngest1SettingsIndexRefreshIntervalValue1 = -1 +) + // Defines values for GetSyntheticMonitorsParamsMonitorTypes0. const ( GetSyntheticMonitorsParamsMonitorTypes0Browser GetSyntheticMonitorsParamsMonitorTypes0 = "browser" @@ -16565,6 +16592,15 @@ type SecurityEndpointManagementAPIKillProcessRouteResponse = map[string]interfac // SecurityEndpointManagementAPIKuery A KQL string. type SecurityEndpointManagementAPIKuery = string +// SecurityEndpointManagementAPIMDERunScriptParameters Parameters for Run Script response action against Microsoft Defender Endpoint agent type. +type SecurityEndpointManagementAPIMDERunScriptParameters struct { + // Args Optional command line arguments for the script. + Args *string `json:"args,omitempty"` + + // ScriptName The name of the script to execute from the cloud storage. + ScriptName string `json:"scriptName"` +} + // SecurityEndpointManagementAPIMetadataListResponse defines model for Security_Endpoint_Management_API_MetadataListResponse. type SecurityEndpointManagementAPIMetadataListResponse = map[string]interface{} @@ -17212,12 +17248,40 @@ type SecurityEntityAnalyticsAPIMonitoredUserDoc struct { } `json:"user,omitempty"` } +// SecurityEntityAnalyticsAPIMonitoredUserUpdateDoc defines model for Security_Entity_Analytics_API_MonitoredUserUpdateDoc. +type SecurityEntityAnalyticsAPIMonitoredUserUpdateDoc struct { + EntityAnalyticsMonitoring *struct { + Labels *[]struct { + Field *string `json:"field,omitempty"` + Source *string `json:"source,omitempty"` + Value *string `json:"value,omitempty"` + } `json:"labels,omitempty"` + } `json:"entity_analytics_monitoring,omitempty"` + Id *string `json:"id,omitempty"` + Labels *struct { + SourceIds *[]string `json:"source_ids,omitempty"` + SourceIntegrations *[]string `json:"source_integrations,omitempty"` + Sources *[]interface{} `json:"sources,omitempty"` + } `json:"labels,omitempty"` + User *struct { + // IsPrivileged Indicates if the user is privileged. + IsPrivileged *bool `json:"is_privileged,omitempty"` + Name *string `json:"name,omitempty"` + } `json:"user,omitempty"` +} + // SecurityEntityAnalyticsAPIMonitoringEngineDescriptor defines model for Security_Entity_Analytics_API_MonitoringEngineDescriptor. type SecurityEntityAnalyticsAPIMonitoringEngineDescriptor struct { + Error *struct { + // Message Error message typically only present if the engine is in error state + Message *string `json:"message,omitempty"` + } `json:"error,omitempty"` + + // Status The status of the Privilege Monitoring Engine Status SecurityEntityAnalyticsAPIPrivilegeMonitoringEngineStatus `json:"status"` } -// SecurityEntityAnalyticsAPIPrivilegeMonitoringEngineStatus defines model for Security_Entity_Analytics_API_PrivilegeMonitoringEngineStatus. +// SecurityEntityAnalyticsAPIPrivilegeMonitoringEngineStatus The status of the Privilege Monitoring Engine type SecurityEntityAnalyticsAPIPrivilegeMonitoringEngineStatus string // SecurityEntityAnalyticsAPIPrivmonUserCsvUploadErrorItem defines model for Security_Entity_Analytics_API_PrivmonUserCsvUploadErrorItem. @@ -19925,6 +19989,7 @@ type AgentPolicy struct { DataOutputId *string `json:"data_output_id,omitempty"` Description *string `json:"description,omitempty"` DownloadSourceId *string `json:"download_source_id,omitempty"` + FipsAgents *float32 `json:"fips_agents,omitempty"` FleetServerHostId *string `json:"fleet_server_host_id,omitempty"` // GlobalDataTags User defined data tags that are added to all of the inputs. The values can be strings or numbers. @@ -20002,8 +20067,11 @@ type AgentPolicyPackagePolicies1 = []struct { // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions,omitempty"` Agents *float32 `json:"agents,omitempty"` - CreatedAt string `json:"created_at"` - CreatedBy string `json:"created_by"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id,omitempty"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -20034,6 +20102,7 @@ type AgentPolicyPackagePolicies1 = []struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -20055,11 +20124,14 @@ type AgentPolicyPackagePolicies1 = []struct { SpaceIds *[]string `json:"spaceIds,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless,omitempty"` - UpdatedAt string `json:"updated_at"` - UpdatedBy string `json:"updated_by"` - Vars *AgentPolicy_PackagePolicies_1_Vars `json:"vars,omitempty"` - Version *string `json:"version,omitempty"` + SupportsAgentless *bool `json:"supports_agentless,omitempty"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector,omitempty"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + Vars *AgentPolicy_PackagePolicies_1_Vars `json:"vars,omitempty"` + Version *string `json:"version,omitempty"` } // AgentPolicy_PackagePolicies_1_Elasticsearch_Privileges defines model for AgentPolicy.PackagePolicies.1.Elasticsearch.Privileges. @@ -21870,8 +21942,11 @@ type PackagePolicy struct { // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions,omitempty"` Agents *float32 `json:"agents,omitempty"` - CreatedAt string `json:"created_at"` - CreatedBy string `json:"created_by"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id,omitempty"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -21904,6 +21979,7 @@ type PackagePolicy struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -21923,11 +21999,14 @@ type PackagePolicy struct { SpaceIds *[]string `json:"spaceIds,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless,omitempty"` - UpdatedAt string `json:"updated_at"` - UpdatedBy string `json:"updated_by"` - Vars *map[string]interface{} `json:"vars,omitempty"` - Version *string `json:"version,omitempty"` + SupportsAgentless *bool `json:"supports_agentless,omitempty"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector,omitempty"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + Vars *map[string]interface{} `json:"vars,omitempty"` + Version *string `json:"version,omitempty"` } // PackagePolicy_Elasticsearch_Privileges defines model for PackagePolicy.Elasticsearch.Privileges. @@ -22009,6 +22088,7 @@ type PackagePolicyRequestPackage struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -27697,6 +27777,57 @@ type GetFleetCheckPermissionsParams struct { FleetServerSetup *bool `form:"fleetServerSetup,omitempty" json:"fleetServerSetup,omitempty"` } +// GetFleetCloudConnectorsParams defines parameters for GetFleetCloudConnectors. +type GetFleetCloudConnectorsParams struct { + Page *string `form:"page,omitempty" json:"page,omitempty"` + PerPage *string `form:"perPage,omitempty" json:"perPage,omitempty"` +} + +// PostFleetCloudConnectorsJSONBody defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBody struct { + CloudProvider PostFleetCloudConnectorsJSONBodyCloudProvider `json:"cloudProvider"` + Name string `json:"name"` + Vars map[string]PostFleetCloudConnectorsJSONBody_Vars_AdditionalProperties `json:"vars"` +} + +// PostFleetCloudConnectorsJSONBodyCloudProvider defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBodyCloudProvider string + +// PostFleetCloudConnectorsJSONBodyVars0 defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBodyVars0 = string + +// PostFleetCloudConnectorsJSONBodyVars1 defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBodyVars1 = float32 + +// PostFleetCloudConnectorsJSONBodyVars2 defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBodyVars2 = bool + +// PostFleetCloudConnectorsJSONBodyVars3 defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBodyVars3 struct { + Frozen *bool `json:"frozen,omitempty"` + Type string `json:"type"` + Value PostFleetCloudConnectorsJSONBody_Vars_3_Value `json:"value"` +} + +// PostFleetCloudConnectorsJSONBodyVars3Value0 defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBodyVars3Value0 = string + +// PostFleetCloudConnectorsJSONBodyVars3Value1 defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBodyVars3Value1 struct { + Id string `json:"id"` + IsSecretRef bool `json:"isSecretRef"` +} + +// PostFleetCloudConnectorsJSONBody_Vars_3_Value defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBody_Vars_3_Value struct { + union json.RawMessage +} + +// PostFleetCloudConnectorsJSONBody_Vars_AdditionalProperties defines parameters for PostFleetCloudConnectors. +type PostFleetCloudConnectorsJSONBody_Vars_AdditionalProperties struct { + union json.RawMessage +} + // GetFleetEnrollmentApiKeysParams defines parameters for GetFleetEnrollmentApiKeys. type GetFleetEnrollmentApiKeysParams struct { Page *float32 `form:"page,omitempty" json:"page,omitempty"` @@ -29505,6 +29636,17 @@ type PutStreamsNameJSONBody00 struct { Processing struct { Steps []PutStreamsNameJSONBody_0_0_Stream_Ingest_Processing_Steps_Item `json:"steps"` } `json:"processing"` + Settings struct { + IndexNumberOfReplicas *struct { + Value float32 `json:"value"` + } `json:"index.number_of_replicas,omitempty"` + IndexNumberOfShards *struct { + Value float32 `json:"value"` + } `json:"index.number_of_shards,omitempty"` + IndexRefreshInterval *struct { + Value PutStreamsNameJSONBody_0_0_Stream_Ingest_Settings_IndexRefreshInterval_Value `json:"value"` + } `json:"index.refresh_interval,omitempty"` + } `json:"settings"` } `json:"ingest"` Name interface{} `json:"name,omitempty"` } `json:"stream"` @@ -31397,7 +31539,8 @@ type PutStreamsNameJSONBody_0_0_Stream_Ingest_Processing_Steps_0_6_Where struct // PutStreamsNameJSONBody00StreamIngestProcessingSteps1 defines parameters for PutStreamsName. type PutStreamsNameJSONBody00StreamIngestProcessingSteps1 struct { - Where struct { + CustomIdentifier *string `json:"customIdentifier,omitempty"` + Where struct { Steps []interface{} `json:"steps"` } `json:"where"` } @@ -31407,6 +31550,17 @@ type PutStreamsNameJSONBody_0_0_Stream_Ingest_Processing_Steps_Item struct { union json.RawMessage } +// PutStreamsNameJSONBody00StreamIngestSettingsIndexRefreshIntervalValue0 defines parameters for PutStreamsName. +type PutStreamsNameJSONBody00StreamIngestSettingsIndexRefreshIntervalValue0 = string + +// PutStreamsNameJSONBody00StreamIngestSettingsIndexRefreshIntervalValue1 defines parameters for PutStreamsName. +type PutStreamsNameJSONBody00StreamIngestSettingsIndexRefreshIntervalValue1 float32 + +// PutStreamsNameJSONBody_0_0_Stream_Ingest_Settings_IndexRefreshInterval_Value defines parameters for PutStreamsName. +type PutStreamsNameJSONBody_0_0_Stream_Ingest_Settings_IndexRefreshInterval_Value struct { + union json.RawMessage +} + // PutStreamsNameJSONBody01 defines parameters for PutStreamsName. type PutStreamsNameJSONBody01 struct { Dashboards []string `json:"dashboards"` @@ -31424,6 +31578,17 @@ type PutStreamsNameJSONBody01 struct { Processing struct { Steps []PutStreamsNameJSONBody_0_1_Stream_Ingest_Processing_Steps_Item `json:"steps"` } `json:"processing"` + Settings struct { + IndexNumberOfReplicas *struct { + Value float32 `json:"value"` + } `json:"index.number_of_replicas,omitempty"` + IndexNumberOfShards *struct { + Value float32 `json:"value"` + } `json:"index.number_of_shards,omitempty"` + IndexRefreshInterval *struct { + Value PutStreamsNameJSONBody_0_1_Stream_Ingest_Settings_IndexRefreshInterval_Value `json:"value"` + } `json:"index.refresh_interval,omitempty"` + } `json:"settings"` } `json:"ingest"` Name interface{} `json:"name,omitempty"` } `json:"stream"` @@ -33316,7 +33481,8 @@ type PutStreamsNameJSONBody_0_1_Stream_Ingest_Processing_Steps_0_6_Where struct // PutStreamsNameJSONBody01StreamIngestProcessingSteps1 defines parameters for PutStreamsName. type PutStreamsNameJSONBody01StreamIngestProcessingSteps1 struct { - Where struct { + CustomIdentifier *string `json:"customIdentifier,omitempty"` + Where struct { Steps []interface{} `json:"steps"` } `json:"where"` } @@ -33326,6 +33492,17 @@ type PutStreamsNameJSONBody_0_1_Stream_Ingest_Processing_Steps_Item struct { union json.RawMessage } +// PutStreamsNameJSONBody01StreamIngestSettingsIndexRefreshIntervalValue0 defines parameters for PutStreamsName. +type PutStreamsNameJSONBody01StreamIngestSettingsIndexRefreshIntervalValue0 = string + +// PutStreamsNameJSONBody01StreamIngestSettingsIndexRefreshIntervalValue1 defines parameters for PutStreamsName. +type PutStreamsNameJSONBody01StreamIngestSettingsIndexRefreshIntervalValue1 float32 + +// PutStreamsNameJSONBody_0_1_Stream_Ingest_Settings_IndexRefreshInterval_Value defines parameters for PutStreamsName. +type PutStreamsNameJSONBody_0_1_Stream_Ingest_Settings_IndexRefreshInterval_Value struct { + union json.RawMessage +} + // PutStreamsNameJSONBody1 defines parameters for PutStreamsName. type PutStreamsNameJSONBody1 struct { Dashboards []string `json:"dashboards"` @@ -33650,6 +33827,17 @@ type PutStreamsNameIngestJSONBodyIngest0 struct { Processing struct { Steps []PutStreamsNameIngestJSONBody_Ingest_0_Processing_Steps_Item `json:"steps"` } `json:"processing"` + Settings struct { + IndexNumberOfReplicas *struct { + Value float32 `json:"value"` + } `json:"index.number_of_replicas,omitempty"` + IndexNumberOfShards *struct { + Value float32 `json:"value"` + } `json:"index.number_of_shards,omitempty"` + IndexRefreshInterval *struct { + Value PutStreamsNameIngestJSONBody_Ingest_0_Settings_IndexRefreshInterval_Value `json:"value"` + } `json:"index.refresh_interval,omitempty"` + } `json:"settings"` Wired struct { Fields map[string]map[string]PutStreamsNameIngestJSONBody_Ingest_0_Wired_Fields_AdditionalProperties `json:"fields"` Routing []struct { @@ -35547,7 +35735,8 @@ type PutStreamsNameIngestJSONBody_Ingest_0_Processing_Steps_0_6_Where struct { // PutStreamsNameIngestJSONBodyIngest0ProcessingSteps1 defines parameters for PutStreamsNameIngest. type PutStreamsNameIngestJSONBodyIngest0ProcessingSteps1 struct { - Where struct { + CustomIdentifier *string `json:"customIdentifier,omitempty"` + Where struct { Steps []interface{} `json:"steps"` } `json:"where"` } @@ -35557,6 +35746,17 @@ type PutStreamsNameIngestJSONBody_Ingest_0_Processing_Steps_Item struct { union json.RawMessage } +// PutStreamsNameIngestJSONBodyIngest0SettingsIndexRefreshIntervalValue0 defines parameters for PutStreamsNameIngest. +type PutStreamsNameIngestJSONBodyIngest0SettingsIndexRefreshIntervalValue0 = string + +// PutStreamsNameIngestJSONBodyIngest0SettingsIndexRefreshIntervalValue1 defines parameters for PutStreamsNameIngest. +type PutStreamsNameIngestJSONBodyIngest0SettingsIndexRefreshIntervalValue1 float32 + +// PutStreamsNameIngestJSONBody_Ingest_0_Settings_IndexRefreshInterval_Value defines parameters for PutStreamsNameIngest. +type PutStreamsNameIngestJSONBody_Ingest_0_Settings_IndexRefreshInterval_Value struct { + union json.RawMessage +} + // PutStreamsNameIngestJSONBodyIngest0WiredFields0 defines parameters for PutStreamsNameIngest. type PutStreamsNameIngestJSONBodyIngest0WiredFields0 struct { union json.RawMessage @@ -35863,6 +36063,17 @@ type PutStreamsNameIngestJSONBodyIngest1 struct { Processing struct { Steps []PutStreamsNameIngestJSONBody_Ingest_1_Processing_Steps_Item `json:"steps"` } `json:"processing"` + Settings struct { + IndexNumberOfReplicas *struct { + Value float32 `json:"value"` + } `json:"index.number_of_replicas,omitempty"` + IndexNumberOfShards *struct { + Value float32 `json:"value"` + } `json:"index.number_of_shards,omitempty"` + IndexRefreshInterval *struct { + Value PutStreamsNameIngestJSONBody_Ingest_1_Settings_IndexRefreshInterval_Value `json:"value"` + } `json:"index.refresh_interval,omitempty"` + } `json:"settings"` } // PutStreamsNameIngestJSONBodyIngest1ClassicFieldOverrides0 defines parameters for PutStreamsNameIngest. @@ -37803,7 +38014,8 @@ type PutStreamsNameIngestJSONBody_Ingest_1_Processing_Steps_0_6_Where struct { // PutStreamsNameIngestJSONBodyIngest1ProcessingSteps1 defines parameters for PutStreamsNameIngest. type PutStreamsNameIngestJSONBodyIngest1ProcessingSteps1 struct { - Where struct { + CustomIdentifier *string `json:"customIdentifier,omitempty"` + Where struct { Steps []interface{} `json:"steps"` } `json:"where"` } @@ -37813,6 +38025,17 @@ type PutStreamsNameIngestJSONBody_Ingest_1_Processing_Steps_Item struct { union json.RawMessage } +// PutStreamsNameIngestJSONBodyIngest1SettingsIndexRefreshIntervalValue0 defines parameters for PutStreamsNameIngest. +type PutStreamsNameIngestJSONBodyIngest1SettingsIndexRefreshIntervalValue0 = string + +// PutStreamsNameIngestJSONBodyIngest1SettingsIndexRefreshIntervalValue1 defines parameters for PutStreamsNameIngest. +type PutStreamsNameIngestJSONBodyIngest1SettingsIndexRefreshIntervalValue1 float32 + +// PutStreamsNameIngestJSONBody_Ingest_1_Settings_IndexRefreshInterval_Value defines parameters for PutStreamsNameIngest. +type PutStreamsNameIngestJSONBody_Ingest_1_Settings_IndexRefreshInterval_Value struct { + union json.RawMessage +} + // PutStreamsNameIngestJSONBody_Ingest defines parameters for PutStreamsNameIngest. type PutStreamsNameIngestJSONBody_Ingest struct { union json.RawMessage @@ -38775,7 +38998,7 @@ type CreatePrivMonUserJSONRequestBody = SecurityEntityAnalyticsAPIUserName type PrivmonBulkUploadUsersCSVMultipartRequestBody PrivmonBulkUploadUsersCSVMultipartBody // UpdatePrivMonUserJSONRequestBody defines body for UpdatePrivMonUser for application/json ContentType. -type UpdatePrivMonUserJSONRequestBody = SecurityEntityAnalyticsAPIMonitoredUserDoc +type UpdatePrivMonUserJSONRequestBody = SecurityEntityAnalyticsAPIMonitoredUserUpdateDoc // InitEntityStoreJSONRequestBody defines body for InitEntityStore for application/json ContentType. type InitEntityStoreJSONRequestBody InitEntityStoreJSONBody @@ -38861,6 +39084,9 @@ type PostFleetAgentsAgentidUnenrollJSONRequestBody PostFleetAgentsAgentidUnenrol // PostFleetAgentsAgentidUpgradeJSONRequestBody defines body for PostFleetAgentsAgentidUpgrade for application/json ContentType. type PostFleetAgentsAgentidUpgradeJSONRequestBody PostFleetAgentsAgentidUpgradeJSONBody +// PostFleetCloudConnectorsJSONRequestBody defines body for PostFleetCloudConnectors for application/json ContentType. +type PostFleetCloudConnectorsJSONRequestBody PostFleetCloudConnectorsJSONBody + // PostFleetEnrollmentApiKeysJSONRequestBody defines body for PostFleetEnrollmentApiKeys for application/json ContentType. type PostFleetEnrollmentApiKeysJSONRequestBody PostFleetEnrollmentApiKeysJSONBody @@ -51577,7 +51803,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 = "avg" + v.Aggregation = "cardinality" b, err := json.Marshal(v) t.union = b return err @@ -51585,7 +51811,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 = "avg" + v.Aggregation = "cardinality" b, err := json.Marshal(v) if err != nil { return err @@ -51666,7 +51892,7 @@ func (t SLOsIndicatorPropertiesTimesliceMetric_Params_Metric_Metrics_Item) Value return nil, err } switch discriminator { - case "avg": + case "cardinality": return t.AsSLOsTimesliceMetricBasicMetricWithField() case "doc_count": return t.AsSLOsTimesliceMetricDocCountMetric() @@ -55337,6 +55563,32 @@ func (t *SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters) Merg return err } +// AsSecurityEndpointManagementAPIMDERunScriptParameters returns the union data inside the SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters as a SecurityEndpointManagementAPIMDERunScriptParameters +func (t SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters) AsSecurityEndpointManagementAPIMDERunScriptParameters() (SecurityEndpointManagementAPIMDERunScriptParameters, error) { + var body SecurityEndpointManagementAPIMDERunScriptParameters + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromSecurityEndpointManagementAPIMDERunScriptParameters overwrites any union data inside the SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters as the provided SecurityEndpointManagementAPIMDERunScriptParameters +func (t *SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters) FromSecurityEndpointManagementAPIMDERunScriptParameters(v SecurityEndpointManagementAPIMDERunScriptParameters) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeSecurityEndpointManagementAPIMDERunScriptParameters performs a merge with any union data inside the SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters, using the provided SecurityEndpointManagementAPIMDERunScriptParameters +func (t *SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters) MergeSecurityEndpointManagementAPIMDERunScriptParameters(v SecurityEndpointManagementAPIMDERunScriptParameters) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + func (t SecurityEndpointManagementAPIRunScriptRouteRequestBody_Parameters) MarshalJSON() ([]byte, error) { b, err := t.union.MarshalJSON() return b, err @@ -64839,6 +65091,14 @@ type ClientInterface interface { // GetFleetCheckPermissions request GetFleetCheckPermissions(ctx context.Context, params *GetFleetCheckPermissionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetFleetCloudConnectors request + GetFleetCloudConnectors(ctx context.Context, params *GetFleetCloudConnectorsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostFleetCloudConnectorsWithBody request with any body + PostFleetCloudConnectorsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostFleetCloudConnectors(ctx context.Context, body PostFleetCloudConnectorsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetFleetDataStreams request GetFleetDataStreams(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -69347,6 +69607,42 @@ func (c *Client) GetFleetCheckPermissions(ctx context.Context, params *GetFleetC return c.Client.Do(req) } +func (c *Client) GetFleetCloudConnectors(ctx context.Context, params *GetFleetCloudConnectorsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetFleetCloudConnectorsRequest(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) PostFleetCloudConnectorsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostFleetCloudConnectorsRequestWithBody(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) PostFleetCloudConnectors(ctx context.Context, body PostFleetCloudConnectorsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostFleetCloudConnectorsRequest(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) GetFleetDataStreams(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetFleetDataStreamsRequest(c.Server) if err != nil { @@ -85155,6 +85451,111 @@ func NewGetFleetCheckPermissionsRequest(server string, params *GetFleetCheckPerm return req, nil } +// NewGetFleetCloudConnectorsRequest generates requests for GetFleetCloudConnectors +func NewGetFleetCloudConnectorsRequest(server string, params *GetFleetCloudConnectorsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/fleet/cloud_connectors") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Page != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "page", runtime.ParamLocationQuery, *params.Page); 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.PerPage != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "perPage", runtime.ParamLocationQuery, *params.PerPage); 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 +} + +// NewPostFleetCloudConnectorsRequest calls the generic PostFleetCloudConnectors builder with application/json body +func NewPostFleetCloudConnectorsRequest(server string, body PostFleetCloudConnectorsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostFleetCloudConnectorsRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostFleetCloudConnectorsRequestWithBody generates requests for PostFleetCloudConnectors with any type of body +func NewPostFleetCloudConnectorsRequestWithBody(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/fleet/cloud_connectors") + 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 +} + // NewGetFleetDataStreamsRequest generates requests for GetFleetDataStreams func NewGetFleetDataStreamsRequest(server string) (*http.Request, error) { var err error @@ -99942,6 +100343,14 @@ type ClientWithResponsesInterface interface { // GetFleetCheckPermissionsWithResponse request GetFleetCheckPermissionsWithResponse(ctx context.Context, params *GetFleetCheckPermissionsParams, reqEditors ...RequestEditorFn) (*GetFleetCheckPermissionsResponse, error) + // GetFleetCloudConnectorsWithResponse request + GetFleetCloudConnectorsWithResponse(ctx context.Context, params *GetFleetCloudConnectorsParams, reqEditors ...RequestEditorFn) (*GetFleetCloudConnectorsResponse, error) + + // PostFleetCloudConnectorsWithBodyWithResponse request with any body + PostFleetCloudConnectorsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFleetCloudConnectorsResponse, error) + + PostFleetCloudConnectorsWithResponse(ctx context.Context, body PostFleetCloudConnectorsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFleetCloudConnectorsResponse, error) + // GetFleetDataStreamsWithResponse request GetFleetDataStreamsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetFleetDataStreamsResponse, error) @@ -105836,6 +106245,7 @@ type InitMonitoringEngineResponse struct { Body []byte HTTPResponse *http.Response JSON200 *SecurityEntityAnalyticsAPIMonitoringEngineDescriptor + JSON500 *SecurityEntityAnalyticsAPIMonitoringEngineDescriptor } // Status returns HTTPResponse.Status @@ -105890,6 +106300,8 @@ type PrivMonHealthResponse struct { Error *struct { Message *string `json:"message,omitempty"` } `json:"error,omitempty"` + + // Status The status of the Privilege Monitoring Engine Status SecurityEntityAnalyticsAPIPrivilegeMonitoringEngineStatus `json:"status"` } } @@ -107218,6 +107630,7 @@ type PostFleetAgentPoliciesBulkGetResponse struct { DataOutputId *string `json:"data_output_id"` Description *string `json:"description,omitempty"` DownloadSourceId *string `json:"download_source_id"` + FipsAgents *float32 `json:"fips_agents,omitempty"` FleetServerHostId *string `json:"fleet_server_host_id"` // GlobalDataTags User defined data tags that are added to all of the inputs. The values can be strings or numbers. @@ -107306,8 +107719,11 @@ type PostFleetAgentPoliciesBulkGet200ItemsPackagePolicies1 = []struct { // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions"` Agents *float32 `json:"agents,omitempty"` - CreatedAt string `json:"created_at"` - CreatedBy string `json:"created_by"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -107338,6 +107754,7 @@ type PostFleetAgentPoliciesBulkGet200ItemsPackagePolicies1 = []struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -107359,11 +107776,14 @@ type PostFleetAgentPoliciesBulkGet200ItemsPackagePolicies1 = []struct { SpaceIds *[]string `json:"spaceIds,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless"` - UpdatedAt string `json:"updated_at"` - UpdatedBy string `json:"updated_by"` - Vars *PostFleetAgentPoliciesBulkGet_200_Items_PackagePolicies_1_Vars `json:"vars,omitempty"` - Version *string `json:"version,omitempty"` + SupportsAgentless *bool `json:"supports_agentless"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + Vars *PostFleetAgentPoliciesBulkGet_200_Items_PackagePolicies_1_Vars `json:"vars,omitempty"` + Version *string `json:"version,omitempty"` } type PostFleetAgentPoliciesBulkGet_200_Items_PackagePolicies_1_Elasticsearch_Privileges struct { Cluster *[]string `json:"cluster,omitempty"` @@ -107731,6 +108151,7 @@ type PostFleetAgentPoliciesAgentpolicyidCopyResponse struct { DataOutputId *string `json:"data_output_id"` Description *string `json:"description,omitempty"` DownloadSourceId *string `json:"download_source_id"` + FipsAgents *float32 `json:"fips_agents,omitempty"` FleetServerHostId *string `json:"fleet_server_host_id"` // GlobalDataTags User defined data tags that are added to all of the inputs. The values can be strings or numbers. @@ -107819,8 +108240,11 @@ type PostFleetAgentPoliciesAgentpolicyidCopy200ItemPackagePolicies1 = []struct { // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions"` Agents *float32 `json:"agents,omitempty"` - CreatedAt string `json:"created_at"` - CreatedBy string `json:"created_by"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -107851,6 +108275,7 @@ type PostFleetAgentPoliciesAgentpolicyidCopy200ItemPackagePolicies1 = []struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -107872,11 +108297,14 @@ type PostFleetAgentPoliciesAgentpolicyidCopy200ItemPackagePolicies1 = []struct { SpaceIds *[]string `json:"spaceIds,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless"` - UpdatedAt string `json:"updated_at"` - UpdatedBy string `json:"updated_by"` - Vars *PostFleetAgentPoliciesAgentpolicyidCopy_200_Item_PackagePolicies_1_Vars `json:"vars,omitempty"` - Version *string `json:"version,omitempty"` + SupportsAgentless *bool `json:"supports_agentless"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + Vars *PostFleetAgentPoliciesAgentpolicyidCopy_200_Item_PackagePolicies_1_Vars `json:"vars,omitempty"` + Version *string `json:"version,omitempty"` } type PostFleetAgentPoliciesAgentpolicyidCopy_200_Item_PackagePolicies_1_Elasticsearch_Privileges struct { Cluster *[]string `json:"cluster,omitempty"` @@ -109538,6 +109966,82 @@ func (r GetFleetCheckPermissionsResponse) StatusCode() int { return 0 } +type GetFleetCloudConnectorsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]struct { + CloudProvider string `json:"cloudProvider"` + CreatedAt string `json:"created_at"` + Id string `json:"id"` + Name string `json:"name"` + Namespace *string `json:"namespace,omitempty"` + PackagePolicyCount float32 `json:"packagePolicyCount"` + UpdatedAt string `json:"updated_at"` + Vars map[string]interface{} `json:"vars"` + } + JSON400 *struct { + Attributes interface{} `json:"attributes"` + Error *string `json:"error,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + Message string `json:"message"` + StatusCode *float32 `json:"statusCode,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r GetFleetCloudConnectorsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetFleetCloudConnectorsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostFleetCloudConnectorsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + CloudProvider string `json:"cloudProvider"` + CreatedAt string `json:"created_at"` + Id string `json:"id"` + Name string `json:"name"` + Namespace *string `json:"namespace,omitempty"` + PackagePolicyCount float32 `json:"packagePolicyCount"` + UpdatedAt string `json:"updated_at"` + Vars map[string]interface{} `json:"vars"` + } + JSON400 *struct { + Attributes interface{} `json:"attributes"` + Error *string `json:"error,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + Message string `json:"message"` + StatusCode *float32 `json:"statusCode,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r PostFleetCloudConnectorsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostFleetCloudConnectorsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type GetFleetDataStreamsResponse struct { Body []byte HTTPResponse *http.Response @@ -111581,8 +112085,11 @@ type PostFleetPackagePoliciesBulkGetResponse struct { // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions"` Agents *float32 `json:"agents,omitempty"` - CreatedAt string `json:"created_at"` - CreatedBy string `json:"created_by"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -111613,6 +112120,7 @@ type PostFleetPackagePoliciesBulkGetResponse struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -111634,11 +112142,14 @@ type PostFleetPackagePoliciesBulkGetResponse struct { SpaceIds *[]string `json:"spaceIds,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless"` - UpdatedAt string `json:"updated_at"` - UpdatedBy string `json:"updated_by"` - Vars *PostFleetPackagePoliciesBulkGet_200_Items_Vars `json:"vars,omitempty"` - Version *string `json:"version,omitempty"` + SupportsAgentless *bool `json:"supports_agentless"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + Vars *PostFleetPackagePoliciesBulkGet_200_Items_Vars `json:"vars,omitempty"` + Version *string `json:"version,omitempty"` } `json:"items"` } JSON400 *struct { @@ -111816,6 +112327,7 @@ type PostFleetPackagePoliciesDeleteResponse struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -111970,8 +112482,11 @@ type PostFleetPackagePoliciesUpgradeDryrun200Diff0 struct { // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions"` Agents *float32 `json:"agents,omitempty"` - CreatedAt string `json:"created_at"` - CreatedBy string `json:"created_by"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -112002,6 +112517,7 @@ type PostFleetPackagePoliciesUpgradeDryrun200Diff0 struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -112023,11 +112539,14 @@ type PostFleetPackagePoliciesUpgradeDryrun200Diff0 struct { SpaceIds *[]string `json:"spaceIds,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless"` - UpdatedAt string `json:"updated_at"` - UpdatedBy string `json:"updated_by"` - Vars *PostFleetPackagePoliciesUpgradeDryrun_200_Diff_0_Vars `json:"vars,omitempty"` - Version *string `json:"version,omitempty"` + SupportsAgentless *bool `json:"supports_agentless"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + Vars *PostFleetPackagePoliciesUpgradeDryrun_200_Diff_0_Vars `json:"vars,omitempty"` + Version *string `json:"version,omitempty"` } type PostFleetPackagePoliciesUpgradeDryrun_200_Diff_0_Elasticsearch_Privileges struct { Cluster *[]string `json:"cluster,omitempty"` @@ -112159,8 +112678,11 @@ type PostFleetPackagePoliciesUpgradeDryrun_200_Diff_0_Vars struct { type PostFleetPackagePoliciesUpgradeDryrun200Diff1 struct { // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions"` - CreatedAt *string `json:"created_at,omitempty"` - CreatedBy *string `json:"created_by,omitempty"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id"` + CreatedAt *string `json:"created_at,omitempty"` + CreatedBy *string `json:"created_by,omitempty"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -112250,6 +112772,7 @@ type PostFleetPackagePoliciesUpgradeDryrun200Diff1 struct { Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -112270,9 +112793,12 @@ type PostFleetPackagePoliciesUpgradeDryrun200Diff1 struct { } `json:"secret_references,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless"` - UpdatedAt *string `json:"updated_at,omitempty"` - UpdatedBy *string `json:"updated_by,omitempty"` + SupportsAgentless *bool `json:"supports_agentless"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector"` + UpdatedAt *string `json:"updated_at,omitempty"` + UpdatedBy *string `json:"updated_by,omitempty"` // Vars Package variable (see integration documentation for more information) Vars *map[string]struct { @@ -112794,7 +113320,8 @@ type GetFleetSettingsResponse struct { HTTPResponse *http.Response JSON200 *struct { Item struct { - DeleteUnenrolledAgents *struct { + ActionSecretStorageRequirementsMet *bool `json:"action_secret_storage_requirements_met,omitempty"` + DeleteUnenrolledAgents *struct { Enabled bool `json:"enabled"` IsPreconfigured bool `json:"is_preconfigured"` } `json:"delete_unenrolled_agents,omitempty"` @@ -112844,7 +113371,8 @@ type PutFleetSettingsResponse struct { HTTPResponse *http.Response JSON200 *struct { Item struct { - DeleteUnenrolledAgents *struct { + ActionSecretStorageRequirementsMet *bool `json:"action_secret_storage_requirements_met,omitempty"` + DeleteUnenrolledAgents *struct { Enabled bool `json:"enabled"` IsPreconfigured bool `json:"is_preconfigured"` } `json:"delete_unenrolled_agents,omitempty"` @@ -120642,6 +121170,32 @@ func (c *ClientWithResponses) GetFleetCheckPermissionsWithResponse(ctx context.C return ParseGetFleetCheckPermissionsResponse(rsp) } +// GetFleetCloudConnectorsWithResponse request returning *GetFleetCloudConnectorsResponse +func (c *ClientWithResponses) GetFleetCloudConnectorsWithResponse(ctx context.Context, params *GetFleetCloudConnectorsParams, reqEditors ...RequestEditorFn) (*GetFleetCloudConnectorsResponse, error) { + rsp, err := c.GetFleetCloudConnectors(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetFleetCloudConnectorsResponse(rsp) +} + +// PostFleetCloudConnectorsWithBodyWithResponse request with arbitrary body returning *PostFleetCloudConnectorsResponse +func (c *ClientWithResponses) PostFleetCloudConnectorsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFleetCloudConnectorsResponse, error) { + rsp, err := c.PostFleetCloudConnectorsWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostFleetCloudConnectorsResponse(rsp) +} + +func (c *ClientWithResponses) PostFleetCloudConnectorsWithResponse(ctx context.Context, body PostFleetCloudConnectorsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFleetCloudConnectorsResponse, error) { + rsp, err := c.PostFleetCloudConnectors(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostFleetCloudConnectorsResponse(rsp) +} + // GetFleetDataStreamsWithResponse request returning *GetFleetDataStreamsResponse func (c *ClientWithResponses) GetFleetDataStreamsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetFleetDataStreamsResponse, error) { rsp, err := c.GetFleetDataStreams(ctx, reqEditors...) @@ -130114,6 +130668,13 @@ func ParseInitMonitoringEngineResponse(rsp *http.Response) (*InitMonitoringEngin } response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest SecurityEntityAnalyticsAPIMonitoringEngineDescriptor + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + } return response, nil @@ -130177,6 +130738,8 @@ func ParsePrivMonHealthResponse(rsp *http.Response) (*PrivMonHealthResponse, err Error *struct { Message *string `json:"message,omitempty"` } `json:"error,omitempty"` + + // Status The status of the Privilege Monitoring Engine Status SecurityEntityAnalyticsAPIPrivilegeMonitoringEngineStatus `json:"status"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -132133,6 +132696,7 @@ func ParsePostFleetAgentPoliciesBulkGetResponse(rsp *http.Response) (*PostFleetA DataOutputId *string `json:"data_output_id"` Description *string `json:"description,omitempty"` DownloadSourceId *string `json:"download_source_id"` + FipsAgents *float32 `json:"fips_agents,omitempty"` FleetServerHostId *string `json:"fleet_server_host_id"` // GlobalDataTags User defined data tags that are added to all of the inputs. The values can be strings or numbers. @@ -132505,6 +133069,7 @@ func ParsePostFleetAgentPoliciesAgentpolicyidCopyResponse(rsp *http.Response) (* DataOutputId *string `json:"data_output_id"` Description *string `json:"description,omitempty"` DownloadSourceId *string `json:"download_source_id"` + FipsAgents *float32 `json:"fips_agents,omitempty"` FleetServerHostId *string `json:"fleet_server_host_id"` // GlobalDataTags User defined data tags that are added to all of the inputs. The values can be strings or numbers. @@ -134162,6 +134727,102 @@ func ParseGetFleetCheckPermissionsResponse(rsp *http.Response) (*GetFleetCheckPe return response, nil } +// ParseGetFleetCloudConnectorsResponse parses an HTTP response from a GetFleetCloudConnectorsWithResponse call +func ParseGetFleetCloudConnectorsResponse(rsp *http.Response) (*GetFleetCloudConnectorsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetFleetCloudConnectorsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []struct { + CloudProvider string `json:"cloudProvider"` + CreatedAt string `json:"created_at"` + Id string `json:"id"` + Name string `json:"name"` + Namespace *string `json:"namespace,omitempty"` + PackagePolicyCount float32 `json:"packagePolicyCount"` + UpdatedAt string `json:"updated_at"` + Vars map[string]interface{} `json:"vars"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest struct { + Attributes interface{} `json:"attributes"` + Error *string `json:"error,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + Message string `json:"message"` + StatusCode *float32 `json:"statusCode,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + } + + return response, nil +} + +// ParsePostFleetCloudConnectorsResponse parses an HTTP response from a PostFleetCloudConnectorsWithResponse call +func ParsePostFleetCloudConnectorsResponse(rsp *http.Response) (*PostFleetCloudConnectorsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostFleetCloudConnectorsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + CloudProvider string `json:"cloudProvider"` + CreatedAt string `json:"created_at"` + Id string `json:"id"` + Name string `json:"name"` + Namespace *string `json:"namespace,omitempty"` + PackagePolicyCount float32 `json:"packagePolicyCount"` + UpdatedAt string `json:"updated_at"` + Vars map[string]interface{} `json:"vars"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest struct { + Attributes interface{} `json:"attributes"` + Error *string `json:"error,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + Message string `json:"message"` + StatusCode *float32 `json:"statusCode,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + } + + return response, nil +} + // ParseGetFleetDataStreamsResponse parses an HTTP response from a GetFleetDataStreamsWithResponse call func ParseGetFleetDataStreamsResponse(rsp *http.Response) (*GetFleetDataStreamsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -136388,8 +137049,11 @@ func ParsePostFleetPackagePoliciesBulkGetResponse(rsp *http.Response) (*PostFlee // AdditionalDatastreamsPermissions Additional datastream permissions, that will be added to the agent policy. AdditionalDatastreamsPermissions *[]string `json:"additional_datastreams_permissions"` Agents *float32 `json:"agents,omitempty"` - CreatedAt string `json:"created_at"` - CreatedBy string `json:"created_by"` + + // CloudConnectorId ID of the cloud connector associated with this package policy. + CloudConnectorId *string `json:"cloud_connector_id"` + CreatedAt string `json:"created_at"` + CreatedBy string `json:"created_by"` // Description Package policy description Description *string `json:"description,omitempty"` @@ -136420,6 +137084,7 @@ func ParsePostFleetPackagePoliciesBulkGetResponse(rsp *http.Response) (*PostFlee Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -136441,11 +137106,14 @@ func ParsePostFleetPackagePoliciesBulkGetResponse(rsp *http.Response) (*PostFlee SpaceIds *[]string `json:"spaceIds,omitempty"` // SupportsAgentless Indicates whether the package policy belongs to an agentless agent policy. - SupportsAgentless *bool `json:"supports_agentless"` - UpdatedAt string `json:"updated_at"` - UpdatedBy string `json:"updated_by"` - Vars *PostFleetPackagePoliciesBulkGet_200_Items_Vars `json:"vars,omitempty"` - Version *string `json:"version,omitempty"` + SupportsAgentless *bool `json:"supports_agentless"` + + // SupportsCloudConnector Indicates whether the package policy supports cloud connectors. + SupportsCloudConnector *bool `json:"supports_cloud_connector"` + UpdatedAt string `json:"updated_at"` + UpdatedBy string `json:"updated_by"` + Vars *PostFleetPackagePoliciesBulkGet_200_Items_Vars `json:"vars,omitempty"` + Version *string `json:"version,omitempty"` } `json:"items"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -136512,6 +137180,7 @@ func ParsePostFleetPackagePoliciesDeleteResponse(rsp *http.Response) (*PostFleet Tsdb *bool `json:"tsdb,omitempty"` } `json:"features"` } `json:"experimental_data_stream_features,omitempty"` + FipsCompatible *bool `json:"fips_compatible,omitempty"` // Name Package name Name string `json:"name"` @@ -137235,7 +137904,8 @@ func ParseGetFleetSettingsResponse(rsp *http.Response) (*GetFleetSettingsRespons case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { Item struct { - DeleteUnenrolledAgents *struct { + ActionSecretStorageRequirementsMet *bool `json:"action_secret_storage_requirements_met,omitempty"` + DeleteUnenrolledAgents *struct { Enabled bool `json:"enabled"` IsPreconfigured bool `json:"is_preconfigured"` } `json:"delete_unenrolled_agents,omitempty"` @@ -137299,7 +137969,8 @@ func ParsePutFleetSettingsResponse(rsp *http.Response) (*PutFleetSettingsRespons case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { Item struct { - DeleteUnenrolledAgents *struct { + ActionSecretStorageRequirementsMet *bool `json:"action_secret_storage_requirements_met,omitempty"` + DeleteUnenrolledAgents *struct { Enabled bool `json:"enabled"` IsPreconfigured bool `json:"is_preconfigured"` } `json:"delete_unenrolled_agents,omitempty"` diff --git a/internal/fleet/integration_policy/create.go b/internal/fleet/integration_policy/create.go index 2a47da9b5..d9024792d 100644 --- a/internal/fleet/integration_policy/create.go +++ b/internal/fleet/integration_policy/create.go @@ -22,7 +22,13 @@ func (r *integrationPolicyResource) Create(ctx context.Context, req resource.Cre return } - body, diags := planModel.toAPIModel(ctx, false) + feat, diags := r.buildFeatures(ctx) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + body, diags := planModel.toAPIModel(ctx, false, feat) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return diff --git a/internal/fleet/integration_policy/models.go b/internal/fleet/integration_policy/models.go index 0ffe6014e..8715d3329 100644 --- a/internal/fleet/integration_policy/models.go +++ b/internal/fleet/integration_policy/models.go @@ -2,6 +2,7 @@ package integration_policy import ( "context" + "fmt" "sort" "github.com/elastic/terraform-provider-elasticstack/generated/kbapi" @@ -12,12 +13,17 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) +type features struct { + SupportsPolicyIds bool +} + type integrationPolicyModel struct { ID types.String `tfsdk:"id"` PolicyID types.String `tfsdk:"policy_id"` Name types.String `tfsdk:"name"` Namespace types.String `tfsdk:"namespace"` AgentPolicyID types.String `tfsdk:"agent_policy_id"` + AgentPolicyIDs types.List `tfsdk:"agent_policy_ids"` Description types.String `tfsdk:"description"` Enabled types.Bool `tfsdk:"enabled"` Force types.Bool `tfsdk:"force"` @@ -45,7 +51,27 @@ func (model *integrationPolicyModel) populateFromAPI(ctx context.Context, data * model.PolicyID = types.StringValue(data.Id) model.Name = types.StringValue(data.Name) model.Namespace = types.StringPointerValue(data.Namespace) - model.AgentPolicyID = types.StringPointerValue(data.PolicyId) + + // Only populate the agent policy field that was originally configured + // to avoid Terraform detecting inconsistent state + originallyUsedAgentPolicyID := utils.IsKnown(model.AgentPolicyID) + originallyUsedAgentPolicyIDs := utils.IsKnown(model.AgentPolicyIDs) + + if originallyUsedAgentPolicyID { + // Only set agent_policy_id if it was originally used + model.AgentPolicyID = types.StringPointerValue(data.PolicyId) + } + if originallyUsedAgentPolicyIDs { + // Only set agent_policy_ids if it was originally used + if data.PolicyIds != nil { + agentPolicyIDs, d := types.ListValueFrom(ctx, types.StringType, *data.PolicyIds) + diags.Append(d...) + model.AgentPolicyIDs = agentPolicyIDs + } else { + model.AgentPolicyIDs = types.ListNull(types.StringType) + } + } + model.Description = types.StringPointerValue(data.Description) model.Enabled = types.BoolValue(data.Enabled) model.IntegrationName = types.StringValue(data.Package.Name) @@ -81,9 +107,22 @@ func (model *integrationPolicyModel) populateInputFromAPI(ctx context.Context, i } } -func (model integrationPolicyModel) toAPIModel(ctx context.Context, isUpdate bool) (kbapi.PackagePolicyRequest, diag.Diagnostics) { +func (model integrationPolicyModel) toAPIModel(ctx context.Context, isUpdate bool, feat features) (kbapi.PackagePolicyRequest, diag.Diagnostics) { var diags diag.Diagnostics + // Check if agent_policy_ids is configured and version supports it + if utils.IsKnown(model.AgentPolicyIDs) { + if !feat.SupportsPolicyIds { + return kbapi.PackagePolicyRequest{}, diag.Diagnostics{ + diag.NewAttributeErrorDiagnostic( + path.Root("agent_policy_ids"), + "Unsupported Elasticsearch version", + fmt.Sprintf("Agent policy IDs are only supported in Elastic Stack %s and above", MinVersionPolicyIds), + ), + } + } + } + body := kbapi.PackagePolicyRequest{ Description: model.Description.ValueStringPointer(), Force: model.Force.ValueBoolPointer(), @@ -94,7 +133,21 @@ func (model integrationPolicyModel) toAPIModel(ctx context.Context, isUpdate boo Version: model.IntegrationVersion.ValueString(), }, PolicyId: model.AgentPolicyID.ValueStringPointer(), - Vars: utils.MapRef(utils.NormalizedTypeToMap[any](model.VarsJson, path.Root("vars_json"), &diags)), + PolicyIds: func() *[]string { + if !model.AgentPolicyIDs.IsNull() && !model.AgentPolicyIDs.IsUnknown() { + var policyIDs []string + d := model.AgentPolicyIDs.ElementsAs(ctx, &policyIDs, false) + diags.Append(d...) + return &policyIDs + } + // Only return empty array for 8.15+ when agent_policy_ids is not defined + if feat.SupportsPolicyIds { + emptyArray := []string{} + return &emptyArray + } + return nil + }(), + Vars: utils.MapRef(utils.NormalizedTypeToMap[any](model.VarsJson, path.Root("vars_json"), &diags)), } if isUpdate { diff --git a/internal/fleet/integration_policy/resource.go b/internal/fleet/integration_policy/resource.go index b10e68a80..0343b4dca 100644 --- a/internal/fleet/integration_policy/resource.go +++ b/internal/fleet/integration_policy/resource.go @@ -5,6 +5,9 @@ import ( "fmt" "github.com/elastic/terraform-provider-elasticstack/internal/clients" + "github.com/elastic/terraform-provider-elasticstack/internal/diagutil" + "github.com/hashicorp/go-version" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" ) @@ -16,6 +19,10 @@ var ( _ resource.ResourceWithUpgradeState = &integrationPolicyResource{} ) +var ( + MinVersionPolicyIds = version.Must(version.NewVersion("8.15.0")) +) + // NewResource is a helper function to simplify the provider implementation. func NewResource() resource.Resource { return &integrationPolicyResource{} @@ -44,3 +51,14 @@ func (r *integrationPolicyResource) UpgradeState(context.Context) map[int64]reso 0: {PriorSchema: getSchemaV0(), StateUpgrader: upgradeV0}, } } + +func (r *integrationPolicyResource) buildFeatures(ctx context.Context) (features, diag.Diagnostics) { + supportsPolicyIds, diags := r.client.EnforceMinVersion(ctx, MinVersionPolicyIds) + if diags.HasError() { + return features{}, diagutil.FrameworkDiagsFromSDK(diags) + } + + return features{ + SupportsPolicyIds: supportsPolicyIds, + }, nil +} diff --git a/internal/fleet/integration_policy/resource_test.go b/internal/fleet/integration_policy/resource_test.go index 38d5dd1bb..e91115cf8 100644 --- a/internal/fleet/integration_policy/resource_test.go +++ b/internal/fleet/integration_policy/resource_test.go @@ -21,6 +21,54 @@ import ( ) var minVersionIntegrationPolicy = version.Must(version.NewVersion("8.10.0")) +var minVersionIntegrationPolicyIds = version.Must(version.NewVersion("8.15.0")) + +func TestAccResourceIntegrationPolicyMultipleAgentPolicies(t *testing.T) { + policyName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceIntegrationPolicyDestroy, + ProtoV6ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionIntegrationPolicyIds), + Config: testAccResourceIntegrationPolicyCreateMultipleAgentPolicies(policyName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "name", policyName), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "description", "IntegrationPolicyTest Policy"), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "integration_name", "tcp"), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "integration_version", "1.16.0"), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "agent_policy_ids.#", "2"), + ), + }, + }, + }) +} + +func TestAccResourceIntegrationPolicyBothAgentPolicyFields(t *testing.T) { + policyName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceIntegrationPolicyDestroy, + ProtoV6ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionIntegrationPolicyIds), + Config: testAccResourceIntegrationPolicyCreateWithBothAgentPolicyFields(policyName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "name", policyName), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "description", "IntegrationPolicyTest Policy"), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "integration_name", "tcp"), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "integration_version", "1.16.0"), + resource.TestCheckResourceAttrSet("elasticstack_fleet_integration_policy.test_policy", "agent_policy_id"), + resource.TestCheckResourceAttr("elasticstack_fleet_integration_policy.test_policy", "agent_policy_ids.#", "1"), + ), + }, + }, + }) +} func TestJsonTypes(t *testing.T) { mapBytes, err := json.Marshal(map[string]string{}) @@ -451,3 +499,96 @@ resource "elasticstack_fleet_integration_policy" "test_policy" { } `, common, id, key, id) } + +func testAccResourceIntegrationPolicyCreateMultipleAgentPolicies(id string) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} +resource "elasticstack_fleet_integration" "test_policy" { + name = "tcp" + version = "1.16.0" + force = true +} +resource "elasticstack_fleet_agent_policy" "test_policy_1" { + name = "%s Agent Policy 1" + namespace = "default" + description = "IntegrationPolicyTest Agent Policy 1" + monitor_logs = true + monitor_metrics = true + skip_destroy = false +} +resource "elasticstack_fleet_agent_policy" "test_policy_2" { + name = "%s Agent Policy 2" + namespace = "default" + description = "IntegrationPolicyTest Agent Policy 2" + monitor_logs = true + monitor_metrics = true + skip_destroy = false +} +resource "elasticstack_fleet_integration_policy" "test_policy" { + name = "%s" + namespace = "default" + description = "IntegrationPolicyTest Policy" + agent_policy_ids = [ + elasticstack_fleet_agent_policy.test_policy_1.policy_id, + elasticstack_fleet_agent_policy.test_policy_2.policy_id + ] + integration_name = elasticstack_fleet_integration.test_policy.name + integration_version = elasticstack_fleet_integration.test_policy.version + input { + input_id = "tcp-tcp" + streams_json = jsonencode({ + "tcp.generic": { + "enabled": true + "vars": { + "listen_address": "localhost" + "listen_port": 8080 + "data_stream.dataset": "tcp.generic" + "tags": [] + "syslog_options": "field: message" + "ssl": "" + "custom": "" + } + } + }) + } +} +`, id, id, id) +} + +func testAccResourceIntegrationPolicyCreateWithBothAgentPolicyFields(id string) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} +resource "elasticstack_fleet_integration" "test_policy" { + name = "tcp" + version = "1.16.0" + force = true +} +resource "elasticstack_fleet_agent_policy" "test_policy" { + name = "%s Agent Policy" + namespace = "default" + description = "IntegrationPolicyTest Agent Policy" + monitor_logs = true + monitor_metrics = true + skip_destroy = false +} +resource "elasticstack_fleet_integration_policy" "test_policy" { + name = "%s" + namespace = "default" + description = "IntegrationPolicyTest Policy" + agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id + agent_policy_ids = [elasticstack_fleet_agent_policy.test_policy.policy_id] + integration_name = elasticstack_fleet_integration.test_policy.name + integration_version = elasticstack_fleet_integration.test_policy.version + input { + input_id = "tcp-tcp" + enabled = true + } +} +`, id, id) +} diff --git a/internal/fleet/integration_policy/schema.go b/internal/fleet/integration_policy/schema.go index 903c25a09..742ee98e8 100644 --- a/internal/fleet/integration_policy/schema.go +++ b/internal/fleet/integration_policy/schema.go @@ -6,11 +6,16 @@ import ( "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/types" ) //go:embed resource-description.md @@ -50,8 +55,20 @@ func getSchemaV1() schema.Schema { Required: true, }, "agent_policy_id": schema.StringAttribute{ - Description: "ID of the agent policy.", - Required: true, + Description: "ID of the agent policy.", + Optional: true, + Validators: []validator.String{ + stringvalidator.ConflictsWith(path.Root("agent_policy_ids").Expression()), + }, + }, + "agent_policy_ids": schema.ListAttribute{ + Description: "List of agent policy IDs.", + ElementType: types.StringType, + Optional: true, + Validators: []validator.List{ + listvalidator.ConflictsWith(path.Root("agent_policy_ids").Expression()), + listvalidator.SizeAtLeast(1), + }, }, "description": schema.StringAttribute{ Description: "The description of the integration policy.", diff --git a/internal/fleet/integration_policy/update.go b/internal/fleet/integration_policy/update.go index d094c2c49..82f70dc7a 100644 --- a/internal/fleet/integration_policy/update.go +++ b/internal/fleet/integration_policy/update.go @@ -22,7 +22,13 @@ func (r *integrationPolicyResource) Update(ctx context.Context, req resource.Upd return } - body, diags := planModel.toAPIModel(ctx, true) + feat, diags := r.buildFeatures(ctx) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + body, diags := planModel.toAPIModel(ctx, true, feat) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return diff --git a/internal/fleet/integration_policy/upgrade.go b/internal/fleet/integration_policy/upgrade.go index 7992ce150..1cf0330ac 100644 --- a/internal/fleet/integration_policy/upgrade.go +++ b/internal/fleet/integration_policy/upgrade.go @@ -4,7 +4,7 @@ import ( "context" "github.com/elastic/terraform-provider-elasticstack/internal/utils" - "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -14,6 +14,29 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) +// V0 model structures - used regular string types for JSON fields +type integrationPolicyModelV0 struct { + ID types.String `tfsdk:"id"` + PolicyID types.String `tfsdk:"policy_id"` + Name types.String `tfsdk:"name"` + Namespace types.String `tfsdk:"namespace"` + AgentPolicyID types.String `tfsdk:"agent_policy_id"` + Description types.String `tfsdk:"description"` + Enabled types.Bool `tfsdk:"enabled"` + Force types.Bool `tfsdk:"force"` + IntegrationName types.String `tfsdk:"integration_name"` + IntegrationVersion types.String `tfsdk:"integration_version"` + Input types.List `tfsdk:"input"` //> integrationPolicyInputModelV0 + VarsJson types.String `tfsdk:"vars_json"` +} + +type integrationPolicyInputModelV0 struct { + InputID types.String `tfsdk:"input_id"` + Enabled types.Bool `tfsdk:"enabled"` + StreamsJson types.String `tfsdk:"streams_json"` + VarsJson types.String `tfsdk:"vars_json"` +} + func getSchemaV0() *schema.Schema { return &schema.Schema{ Version: 0, @@ -45,70 +68,84 @@ func getSchemaV0() *schema.Schema { } } -func getInputTypeV0() attr.Type { - return getSchemaV0().Blocks["input"].Type().(attr.TypeWithElementType).ElementType() -} - -type integrationPolicyModelV0 struct { - ID types.String `tfsdk:"id"` - PolicyID types.String `tfsdk:"policy_id"` - Name types.String `tfsdk:"name"` - Namespace types.String `tfsdk:"namespace"` - AgentPolicyID types.String `tfsdk:"agent_policy_id"` - Description types.String `tfsdk:"description"` - Enabled types.Bool `tfsdk:"enabled"` - Force types.Bool `tfsdk:"force"` - IntegrationName types.String `tfsdk:"integration_name"` - IntegrationVersion types.String `tfsdk:"integration_version"` - Input types.List `tfsdk:"input"` //> integrationPolicyInputModelV0 - VarsJson types.String `tfsdk:"vars_json"` -} - -type integrationPolicyInputModelV0 struct { - InputID types.String `tfsdk:"input_id"` - Enabled types.Bool `tfsdk:"enabled"` - StreamsJson types.String `tfsdk:"streams_json"` - VarsJson types.String `tfsdk:"vars_json"` -} - // The schema between V0 and V1 is mostly the same, however vars_json and // streams_json saved "" values to the state when null values were in the // config. jsontypes.Normalized correctly states this is invalid JSON. func upgradeV0(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) { - var stateModel integrationPolicyModelV0 + var stateModelV0 integrationPolicyModelV0 - diags := req.State.Get(ctx, &stateModel) + diags := req.State.Get(ctx, &stateModelV0) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return } - if varsJSON := stateModel.VarsJson.ValueStringPointer(); varsJSON != nil { + // Convert V0 model to V1 model + stateModelV1 := integrationPolicyModel{ + ID: stateModelV0.ID, + PolicyID: stateModelV0.PolicyID, + Name: stateModelV0.Name, + Namespace: stateModelV0.Namespace, + AgentPolicyID: stateModelV0.AgentPolicyID, + AgentPolicyIDs: types.ListNull(types.StringType), // V0 didn't have agent_policy_ids + Description: stateModelV0.Description, + Enabled: stateModelV0.Enabled, + Force: stateModelV0.Force, + IntegrationName: stateModelV0.IntegrationName, + IntegrationVersion: stateModelV0.IntegrationVersion, + } + + // Convert vars_json from string to normalized JSON type + if varsJSON := stateModelV0.VarsJson.ValueStringPointer(); varsJSON != nil { if *varsJSON == "" { - stateModel.VarsJson = types.StringNull() + stateModelV1.VarsJson = jsontypes.NewNormalizedNull() + } else { + stateModelV1.VarsJson = jsontypes.NewNormalizedValue(*varsJSON) } + } else { + stateModelV1.VarsJson = jsontypes.NewNormalizedNull() } - inputs := utils.ListTypeAs[integrationPolicyInputModelV0](ctx, stateModel.Input, path.Root("input"), &resp.Diagnostics) - for index, input := range inputs { - if varsJSON := input.VarsJson.ValueStringPointer(); varsJSON != nil { + // Convert inputs from V0 to V1 + inputsV0 := utils.ListTypeAs[integrationPolicyInputModelV0](ctx, stateModelV0.Input, path.Root("input"), &resp.Diagnostics) + var inputsV1 []integrationPolicyInputModel + + for _, inputV0 := range inputsV0 { + inputV1 := integrationPolicyInputModel{ + InputID: inputV0.InputID, + Enabled: inputV0.Enabled, + } + + // Convert vars_json + if varsJSON := inputV0.VarsJson.ValueStringPointer(); varsJSON != nil { if *varsJSON == "" { - input.VarsJson = types.StringNull() + inputV1.VarsJson = jsontypes.NewNormalizedNull() + } else { + inputV1.VarsJson = jsontypes.NewNormalizedValue(*varsJSON) } + } else { + inputV1.VarsJson = jsontypes.NewNormalizedNull() } - if streamsJSON := input.StreamsJson.ValueStringPointer(); streamsJSON != nil { + + // Convert streams_json + if streamsJSON := inputV0.StreamsJson.ValueStringPointer(); streamsJSON != nil { if *streamsJSON == "" { - input.StreamsJson = types.StringNull() + inputV1.StreamsJson = jsontypes.NewNormalizedNull() + } else { + inputV1.StreamsJson = jsontypes.NewNormalizedValue(*streamsJSON) } + } else { + inputV1.StreamsJson = jsontypes.NewNormalizedNull() } - inputs[index] = input + + inputsV1 = append(inputsV1, inputV1) } - stateModel.Input = utils.ListValueFrom(ctx, inputs, getInputTypeV0(), path.Root("input"), &resp.Diagnostics) + stateModelV1.Input = utils.ListValueFrom(ctx, inputsV1, getInputTypeV1(), path.Root("input"), &resp.Diagnostics) if resp.Diagnostics.HasError() { return } - diags = resp.State.Set(ctx, stateModel) + diags = resp.State.Set(ctx, stateModelV1) resp.Diagnostics.Append(diags...) }