From 17190268d451f012a2639eb2e0c79545c3938423 Mon Sep 17 00:00:00 2001 From: mholttech Date: Mon, 26 Aug 2024 21:01:38 -0700 Subject: [PATCH 01/11] Add support for global data tags in agent policy creation and update --- generated/fleet/fleet.gen.go | 25 ++-- internal/fleet/agent_policy_resource.go | 109 ++++++++++++++++ internal/fleet/agent_policy_resource_test.go | 123 +++++++++++++++++++ 3 files changed, 249 insertions(+), 8 deletions(-) diff --git a/generated/fleet/fleet.gen.go b/generated/fleet/fleet.gen.go index 990ba1b7b..b819d1201 100644 --- a/generated/fleet/fleet.gen.go +++ b/generated/fleet/fleet.gen.go @@ -181,19 +181,26 @@ const ( UpdatePackagePolicyParamsFormatSimplified UpdatePackagePolicyParamsFormat = "simplified" ) +// GlobalDataTag defines the structure for each tag in GlobalDataTags. +type GlobalDataTag struct { + Name string `json:"name"` + Value interface{} `json:"value"` // Value can be either string or number +} + // AgentPolicy defines model for agent_policy. type AgentPolicy struct { AgentFeatures *[]struct { Enabled bool `json:"enabled"` Name string `json:"name"` } `json:"agent_features,omitempty"` - Agents *float32 `json:"agents,omitempty"` - DataOutputId *string `json:"data_output_id"` - Description *string `json:"description,omitempty"` - DownloadSourceId *string `json:"download_source_id"` - FleetServerHostId *string `json:"fleet_server_host_id"` - Id string `json:"id"` - InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` + Agents *float32 `json:"agents,omitempty"` + DataOutputId *string `json:"data_output_id"` + Description *string `json:"description,omitempty"` + DownloadSourceId *string `json:"download_source_id"` + FleetServerHostId *string `json:"fleet_server_host_id"` + Id string `json:"id"` + InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` + GlobalDataTags []GlobalDataTag `json:"global_data_tags,omitempty"` // IsProtected Indicates whether the agent policy has tamper protection enabled. Default false. IsProtected *bool `json:"is_protected,omitempty"` @@ -225,9 +232,10 @@ type AgentPolicyCreateRequest struct { FleetServerHostId *string `json:"fleet_server_host_id"` Id *string `json:"id,omitempty"` InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` + GlobalDataTags []GlobalDataTag `json:"global_data_tags,omitempty"` + MonitoringOutputId *string `json:"monitoring_output_id"` IsProtected *bool `json:"is_protected,omitempty"` MonitoringEnabled *[]AgentPolicyCreateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` - MonitoringOutputId *string `json:"monitoring_output_id"` Name string `json:"name"` Namespace string `json:"namespace"` UnenrollTimeout *float32 `json:"unenroll_timeout,omitempty"` @@ -247,6 +255,7 @@ type AgentPolicyUpdateRequest struct { DownloadSourceId *string `json:"download_source_id"` FleetServerHostId *string `json:"fleet_server_host_id"` InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` + GlobalDataTags []GlobalDataTag `json:"global_data_tags"` IsProtected *bool `json:"is_protected,omitempty"` MonitoringEnabled *[]AgentPolicyUpdateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` MonitoringOutputId *string `json:"monitoring_output_id"` diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index cbd6c054a..ffc438505 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -2,9 +2,12 @@ package fleet import ( "context" + "fmt" fleetapi "github.com/elastic/terraform-provider-elasticstack/generated/fleet" + "github.com/elastic/terraform-provider-elasticstack/internal/clients" "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -15,6 +18,8 @@ const ( monitorMetrics = "metrics" ) +var minVersionGlobalDataTags = version.Must(version.NewVersion("8.15.0")) + func ResourceAgentPolicy() *schema.Resource { agentPolicySchema := map[string]*schema.Schema{ "policy_id": { @@ -79,6 +84,14 @@ func ResourceAgentPolicy() *schema.Resource { Type: schema.TypeBool, Optional: true, }, + "global_data_tags": { + Description: "User-defined data tags that are added to all inputs.", + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, } return &schema.Resource{ @@ -103,6 +116,16 @@ func resourceAgentPolicyCreate(ctx context.Context, d *schema.ResourceData, meta return diags } + apiClient, diags := clients.NewApiClientFromSDKResource(d, meta) + if diags.HasError() { + return diags + } + + serverVersion, diags := apiClient.ServerVersion(ctx) + if diags.HasError() { + return diags + } + if id := d.Get("policy_id").(string); id != "" { d.SetId(id) } @@ -140,6 +163,31 @@ func resourceAgentPolicyCreate(ctx context.Context, d *schema.ResourceData, meta } req.MonitoringEnabled = &monitoringValues + // Add GlobalDataTags + if tags, ok := d.GetOk("global_data_tags"); ok { + tagMap := tags.(map[string]interface{}) + globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) + + if len(tagMap) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { + return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) + } + + for key, value := range tagMap { + globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ + Name: key, + Value: value.(string), + }) + } + + if len(globalDataTags) == 0 { + req.GlobalDataTags = nil + } else { + req.GlobalDataTags = globalDataTags + } + } else { + req.GlobalDataTags = nil + } + policy, diags := fleet.CreateAgentPolicy(ctx, fleetClient, req) if diags.HasError() { return diags @@ -159,6 +207,16 @@ func resourceAgentPolicyUpdate(ctx context.Context, d *schema.ResourceData, meta return diags } + apiClient, diags := clients.NewApiClientFromSDKResource(d, meta) + if diags.HasError() { + return diags + } + + serverVersion, diags := apiClient.ServerVersion(ctx) + if diags.HasError() { + return diags + } + req := fleetapi.AgentPolicyUpdateRequest{ Name: d.Get("name").(string), Namespace: d.Get("namespace").(string), @@ -189,6 +247,29 @@ func resourceAgentPolicyUpdate(ctx context.Context, d *schema.ResourceData, meta } req.MonitoringEnabled = &monitoringValues + // Add GlobalDataTags + if tags, ok := d.GetOk("global_data_tags"); ok { + tagMap := tags.(map[string]interface{}) + + if len(tagMap) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { + return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) + } + if len(tagMap) != 0 { + globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) + for key, value := range tagMap { + globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ + Name: key, + Value: value.(string), + }) + } + req.GlobalDataTags = globalDataTags + } else { + req.GlobalDataTags = nil + } + } else { + req.GlobalDataTags = nil + } + _, diags = fleet.UpdateAgentPolicy(ctx, fleetClient, d.Id(), req) if diags.HasError() { return diags @@ -203,6 +284,16 @@ func resourceAgentPolicyRead(ctx context.Context, d *schema.ResourceData, meta i return diags } + apiClient, diags := clients.NewApiClientFromSDKResource(d, meta) + if diags.HasError() { + return diags + } + + serverVersion, diags := apiClient.ServerVersion(ctx) + if diags.HasError() { + return diags + } + agentPolicy, diags := fleet.ReadAgentPolicy(ctx, fleetClient, d.Id()) if diags.HasError() { return diags @@ -264,6 +355,24 @@ func resourceAgentPolicyRead(ctx context.Context, d *schema.ResourceData, meta i } } + // Add GlobalDataTags + if agentPolicy.GlobalDataTags != nil { + globalDataTags := make(map[string]string, len(agentPolicy.GlobalDataTags)) + if len(globalDataTags) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { + return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) + } + for _, tag := range agentPolicy.GlobalDataTags { + globalDataTags[tag.Name] = tag.Value.(string) // Type assertion to string + } + if err := d.Set("global_data_tags", globalDataTags); err != nil { + return diag.FromErr(err) + } + } else { + if err := d.Set("global_data_tags", nil); err != nil { + return diag.FromErr(err) + } + } + return nil } diff --git a/internal/fleet/agent_policy_resource_test.go b/internal/fleet/agent_policy_resource_test.go index 42995d60b..d36207463 100644 --- a/internal/fleet/agent_policy_resource_test.go +++ b/internal/fleet/agent_policy_resource_test.go @@ -17,9 +17,11 @@ import ( ) var minVersionAgentPolicy = version.Must(version.NewVersion("8.6.0")) +var minVersionGlobalDataTags = version.Must(version.NewVersion("8.15.0")) func TestAccResourceAgentPolicy(t *testing.T) { policyName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + policyNameGlobalDataTags := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, @@ -50,6 +52,51 @@ func TestAccResourceAgentPolicy(t *testing.T) { resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "skip_destroy", "false"), ), }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionGlobalDataTags), + Config: testAccResourceAgentPolicyCreateWithGlobalDataTags(policyNameGlobalDataTags, false), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "name", fmt.Sprintf("Policy %s", policyNameGlobalDataTags)), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "namespace", "default"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "description", "Test Agent Policy"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "monitor_logs", "true"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "monitor_metrics", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "skip_destroy", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag1", "value1"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag2", "value2"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag3", "value3"), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionGlobalDataTags), + Config: testAccResourceAgentPolicyUpdateWithGlobalDataTags(policyNameGlobalDataTags, false), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "name", fmt.Sprintf("Updated Policy %s", policyNameGlobalDataTags)), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "namespace", "default"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "description", "This policy was updated"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "monitor_logs", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "monitor_metrics", "true"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "skip_destroy", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag1", "value1a"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag2", "value2b"), + resource.TestCheckNoResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag3"), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionGlobalDataTags), + Config: testAccResourceAgentPolicyUpdateWithNoGlobalDataTags(policyNameGlobalDataTags, false), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "name", fmt.Sprintf("Updated Policy %s", policyNameGlobalDataTags)), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "namespace", "default"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "description", "This policy was updated without global data tags"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "monitor_logs", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "monitor_metrics", "true"), + resource.TestCheckResourceAttr("elasticstack_fleet_agent_policy.test_policy", "skip_destroy", "false"), + resource.TestCheckNoResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag1"), + resource.TestCheckNoResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag2"), + resource.TestCheckNoResourceAttr("elasticstack_fleet_agent_policy.test_policy", "global_data_tags.tag3"), + ), + }, }, }) } @@ -123,6 +170,82 @@ data "elasticstack_fleet_enrollment_tokens" "test_policy" { `, fmt.Sprintf("Updated Policy %s", id), skipDestroy) } +func testAccResourceAgentPolicyCreateWithGlobalDataTags(id string, skipDestroy bool) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_fleet_agent_policy" "test_policy" { + name = "%s" + namespace = "default" + description = "Test Agent Policy" + monitor_logs = true + monitor_metrics = false + skip_destroy = %t + global_data_tags = { + tag1 = "value1" + tag2 = "value2" + tag3 = "value3" + } +} + +data "elasticstack_fleet_enrollment_tokens" "test_policy" { + policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id +} + +`, fmt.Sprintf("Policy %s", id), skipDestroy) +} + +func testAccResourceAgentPolicyUpdateWithGlobalDataTags(id string, skipDestroy bool) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_fleet_agent_policy" "test_policy" { + name = "%s" + namespace = "default" + description = "This policy was updated" + monitor_logs = false + monitor_metrics = true + skip_destroy = %t + global_data_tags = { + tag1 = "value1a" + tag2 = "value2b" + } +} + +data "elasticstack_fleet_enrollment_tokens" "test_policy" { + policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id +} +`, fmt.Sprintf("Updated Policy %s", id), skipDestroy) +} + +func testAccResourceAgentPolicyUpdateWithNoGlobalDataTags(id string, skipDestroy bool) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_fleet_agent_policy" "test_policy" { + name = "%s" + namespace = "default" + description = "This policy was updated without global data tags" + monitor_logs = false + monitor_metrics = true + skip_destroy = %t +} + +data "elasticstack_fleet_enrollment_tokens" "test_policy" { + policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id +} +`, fmt.Sprintf("Updated Policy %s", id), skipDestroy) +} + func checkResourceAgentPolicyDestroy(s *terraform.State) error { client, err := clients.NewAcceptanceTestingClient() if err != nil { From 2d70ebf25bc43950cb7f52c02f749d75c66a0130 Mon Sep 17 00:00:00 2001 From: mholttech Date: Mon, 26 Aug 2024 21:13:48 -0700 Subject: [PATCH 02/11] code fix and cleanup --- generated/fleet/fleet.gen.go | 2 +- internal/fleet/agent_policy_resource.go | 43 ++++++++++--------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/generated/fleet/fleet.gen.go b/generated/fleet/fleet.gen.go index b819d1201..ca8b6f7db 100644 --- a/generated/fleet/fleet.gen.go +++ b/generated/fleet/fleet.gen.go @@ -255,7 +255,7 @@ type AgentPolicyUpdateRequest struct { DownloadSourceId *string `json:"download_source_id"` FleetServerHostId *string `json:"fleet_server_host_id"` InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` - GlobalDataTags []GlobalDataTag `json:"global_data_tags"` + GlobalDataTags []GlobalDataTag `json:"global_data_tags,omitempty"` IsProtected *bool `json:"is_protected,omitempty"` MonitoringEnabled *[]AgentPolicyUpdateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` MonitoringOutputId *string `json:"monitoring_output_id"` diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index ffc438505..4bc786cd3 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -163,15 +163,13 @@ func resourceAgentPolicyCreate(ctx context.Context, d *schema.ResourceData, meta } req.MonitoringEnabled = &monitoringValues - // Add GlobalDataTags if tags, ok := d.GetOk("global_data_tags"); ok { tagMap := tags.(map[string]interface{}) - globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) - if len(tagMap) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) } + var globalDataTags []fleetapi.GlobalDataTag for key, value := range tagMap { globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ Name: key, @@ -179,13 +177,9 @@ func resourceAgentPolicyCreate(ctx context.Context, d *schema.ResourceData, meta }) } - if len(globalDataTags) == 0 { - req.GlobalDataTags = nil - } else { - req.GlobalDataTags = globalDataTags - } + req.GlobalDataTags = globalDataTags } else { - req.GlobalDataTags = nil + req.GlobalDataTags = []fleetapi.GlobalDataTag{} } policy, diags := fleet.CreateAgentPolicy(ctx, fleetClient, req) @@ -247,27 +241,23 @@ func resourceAgentPolicyUpdate(ctx context.Context, d *schema.ResourceData, meta } req.MonitoringEnabled = &monitoringValues - // Add GlobalDataTags if tags, ok := d.GetOk("global_data_tags"); ok { tagMap := tags.(map[string]interface{}) if len(tagMap) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) } - if len(tagMap) != 0 { - globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) - for key, value := range tagMap { - globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ - Name: key, - Value: value.(string), - }) - } - req.GlobalDataTags = globalDataTags - } else { - req.GlobalDataTags = nil + + globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) + for key, value := range tagMap { + globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ + Name: key, + Value: value.(string), + }) } + req.GlobalDataTags = globalDataTags } else { - req.GlobalDataTags = nil + req.GlobalDataTags = []fleetapi.GlobalDataTag{} } _, diags = fleet.UpdateAgentPolicy(ctx, fleetClient, d.Id(), req) @@ -355,15 +345,16 @@ func resourceAgentPolicyRead(ctx context.Context, d *schema.ResourceData, meta i } } - // Add GlobalDataTags if agentPolicy.GlobalDataTags != nil { - globalDataTags := make(map[string]string, len(agentPolicy.GlobalDataTags)) - if len(globalDataTags) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { + if len(agentPolicy.GlobalDataTags) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) } + + globalDataTags := make(map[string]string, len(agentPolicy.GlobalDataTags)) for _, tag := range agentPolicy.GlobalDataTags { - globalDataTags[tag.Name] = tag.Value.(string) // Type assertion to string + globalDataTags[tag.Name] = tag.Value.(string) } + if err := d.Set("global_data_tags", globalDataTags); err != nil { return diag.FromErr(err) } From 3720216cf7aeacd1a52c3171034b06c9f64bc9b7 Mon Sep 17 00:00:00 2001 From: Michael Holt Date: Mon, 26 Aug 2024 21:41:41 -0700 Subject: [PATCH 03/11] Update Docs --- docs/resources/fleet_agent_policy.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/resources/fleet_agent_policy.md b/docs/resources/fleet_agent_policy.md index 431593ceb..68308ba30 100644 --- a/docs/resources/fleet_agent_policy.md +++ b/docs/resources/fleet_agent_policy.md @@ -41,6 +41,7 @@ resource "elasticstack_fleet_agent_policy" "test_policy" { - `description` (String) The description of the agent policy. - `download_source_id` (String) The identifier for the Elastic Agent binary download server. - `fleet_server_host_id` (String) The identifier for the Fleet server host. +- `global_data_tags` (Map of String) User-defined data tags that are added to all inputs. - `monitor_logs` (Boolean) Enable collection of agent logs. - `monitor_metrics` (Boolean) Enable collection of agent metrics. - `monitoring_output_id` (String) The identifier for monitoring output. From 0245fc692abe6a2b7becccb29d0a51636560f50f Mon Sep 17 00:00:00 2001 From: mholttech Date: Tue, 27 Aug 2024 08:24:10 -0700 Subject: [PATCH 04/11] fix failing test --- generated/fleet/fleet.gen.go | 6 +++--- internal/fleet/agent_policy_resource.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/generated/fleet/fleet.gen.go b/generated/fleet/fleet.gen.go index ca8b6f7db..edeb5a0df 100644 --- a/generated/fleet/fleet.gen.go +++ b/generated/fleet/fleet.gen.go @@ -200,7 +200,7 @@ type AgentPolicy struct { FleetServerHostId *string `json:"fleet_server_host_id"` Id string `json:"id"` InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` - GlobalDataTags []GlobalDataTag `json:"global_data_tags,omitempty"` + GlobalDataTags []GlobalDataTag `json:"global_data_tags"` // IsProtected Indicates whether the agent policy has tamper protection enabled. Default false. IsProtected *bool `json:"is_protected,omitempty"` @@ -232,7 +232,7 @@ type AgentPolicyCreateRequest struct { FleetServerHostId *string `json:"fleet_server_host_id"` Id *string `json:"id,omitempty"` InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` - GlobalDataTags []GlobalDataTag `json:"global_data_tags,omitempty"` + GlobalDataTags []GlobalDataTag `json:"global_data_tags"` MonitoringOutputId *string `json:"monitoring_output_id"` IsProtected *bool `json:"is_protected,omitempty"` MonitoringEnabled *[]AgentPolicyCreateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` @@ -255,7 +255,7 @@ type AgentPolicyUpdateRequest struct { DownloadSourceId *string `json:"download_source_id"` FleetServerHostId *string `json:"fleet_server_host_id"` InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` - GlobalDataTags []GlobalDataTag `json:"global_data_tags,omitempty"` + GlobalDataTags []GlobalDataTag `json:"global_data_tags"` IsProtected *bool `json:"is_protected,omitempty"` MonitoringEnabled *[]AgentPolicyUpdateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` MonitoringOutputId *string `json:"monitoring_output_id"` diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index 4bc786cd3..70c892648 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -165,21 +165,21 @@ func resourceAgentPolicyCreate(ctx context.Context, d *schema.ResourceData, meta if tags, ok := d.GetOk("global_data_tags"); ok { tagMap := tags.(map[string]interface{}) + if len(tagMap) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) } - var globalDataTags []fleetapi.GlobalDataTag + globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) for key, value := range tagMap { globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ Name: key, Value: value.(string), }) } - req.GlobalDataTags = globalDataTags } else { - req.GlobalDataTags = []fleetapi.GlobalDataTag{} + req.GlobalDataTags = make([]fleetapi.GlobalDataTag, 0) // Ensure it's an empty array } policy, diags := fleet.CreateAgentPolicy(ctx, fleetClient, req) @@ -257,7 +257,7 @@ func resourceAgentPolicyUpdate(ctx context.Context, d *schema.ResourceData, meta } req.GlobalDataTags = globalDataTags } else { - req.GlobalDataTags = []fleetapi.GlobalDataTag{} + req.GlobalDataTags = make([]fleetapi.GlobalDataTag, 0) // Ensure it's an empty array } _, diags = fleet.UpdateAgentPolicy(ctx, fleetClient, d.Id(), req) From 36cdf4c17249c6af9df8a350fd6ef5b55349885d Mon Sep 17 00:00:00 2001 From: mholttech Date: Tue, 27 Aug 2024 08:25:04 -0700 Subject: [PATCH 05/11] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a14b5cc7e..d7345f618 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Add support for data_stream `lifecycle` template settings ([#724](https://github.com/elastic/terraform-provider-elasticstack/pull/724)) - Fix a provider panic when `elasticstack_kibana_action_connector` reads a non-existant connector ([#729](https://github.com/elastic/terraform-provider-elasticstack/pull/729)) - Add support for `remote_indicies` to `elasticstack_elasticsearch_security_role` & `elasticstack_kibana_security_role` (#723)[https://github.com/elastic/terraform-provider-elasticstack/pull/723] +- Add support for global data tags in agent policy creation and update (#730)[https://github.com/elastic/terraform-provider-elasticstack/pull/730] ## [0.11.6] - 2024-08-20 From 696d99da72e872dd8d0a32149fdee427096b2fbf Mon Sep 17 00:00:00 2001 From: Michael Holt Date: Tue, 27 Aug 2024 17:41:15 -0700 Subject: [PATCH 06/11] Update internal/fleet/agent_policy_resource.go Co-authored-by: Toby Brain --- internal/fleet/agent_policy_resource.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index 70c892648..075730341 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -346,9 +346,6 @@ func resourceAgentPolicyRead(ctx context.Context, d *schema.ResourceData, meta i } if agentPolicy.GlobalDataTags != nil { - if len(agentPolicy.GlobalDataTags) > 0 && serverVersion.LessThan(minVersionGlobalDataTags) { - return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) - } globalDataTags := make(map[string]string, len(agentPolicy.GlobalDataTags)) for _, tag := range agentPolicy.GlobalDataTags { From 3a3d7182665640376f6c39cc5c453b938283bc81 Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Wed, 28 Aug 2024 17:27:01 +1000 Subject: [PATCH 07/11] Update fleet API to 8.15.0 --- generated/alerting/api_alerting_mocks.go | 4 +- generated/connectors/connectors.gen.go | 2 +- generated/fleet/fleet.gen.go | 536 +++++++++++++++++++---- generated/fleet/getschema.go | 1 + tools/fleet_gen.go | 2 +- 5 files changed, 448 insertions(+), 97 deletions(-) diff --git a/generated/alerting/api_alerting_mocks.go b/generated/alerting/api_alerting_mocks.go index ffab4e81f..d29559207 100644 --- a/generated/alerting/api_alerting_mocks.go +++ b/generated/alerting/api_alerting_mocks.go @@ -1,9 +1,9 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: ./api_alerting.go +// Source: ../generated/alerting/api_alerting.go // // Generated by this command: // -// mockgen -destination=./api_alerting_mocks.go -package=alerting -source ./api_alerting.go AlertingAPI +// mockgen -destination=../generated/alerting/api_alerting_mocks.go -package=alerting -source ../generated/alerting/api_alerting.go AlertingAPI // // Package alerting is a generated GoMock package. diff --git a/generated/connectors/connectors.gen.go b/generated/connectors/connectors.gen.go index c60db1be8..9d2ebb2fe 100644 --- a/generated/connectors/connectors.gen.go +++ b/generated/connectors/connectors.gen.go @@ -1,6 +1,6 @@ // Package connectors provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT. +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. package connectors import ( diff --git a/generated/fleet/fleet.gen.go b/generated/fleet/fleet.gen.go index edeb5a0df..1460ba598 100644 --- a/generated/fleet/fleet.gen.go +++ b/generated/fleet/fleet.gen.go @@ -1,6 +1,6 @@ // Package fleet provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT. +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. package fleet import ( @@ -63,6 +63,15 @@ const ( Visualization KibanaSavedObjectType = "visualization" ) +// Defines values for OutputCreateRequestElasticsearchPreset. +const ( + OutputCreateRequestElasticsearchPresetBalanced OutputCreateRequestElasticsearchPreset = "balanced" + OutputCreateRequestElasticsearchPresetCustom OutputCreateRequestElasticsearchPreset = "custom" + OutputCreateRequestElasticsearchPresetLatency OutputCreateRequestElasticsearchPreset = "latency" + OutputCreateRequestElasticsearchPresetScale OutputCreateRequestElasticsearchPreset = "scale" + OutputCreateRequestElasticsearchPresetThroughput OutputCreateRequestElasticsearchPreset = "throughput" +) + // Defines values for OutputCreateRequestElasticsearchType. const ( OutputCreateRequestElasticsearchTypeElasticsearch OutputCreateRequestElasticsearchType = "elasticsearch" @@ -92,6 +101,20 @@ const ( OutputCreateRequestLogstashTypeLogstash OutputCreateRequestLogstashType = "logstash" ) +// Defines values for OutputCreateRequestRemoteElasticsearchType. +const ( + RemoteElasticsearch OutputCreateRequestRemoteElasticsearchType = "remote_elasticsearch" +) + +// Defines values for OutputUpdateRequestElasticsearchPreset. +const ( + OutputUpdateRequestElasticsearchPresetBalanced OutputUpdateRequestElasticsearchPreset = "balanced" + OutputUpdateRequestElasticsearchPresetCustom OutputUpdateRequestElasticsearchPreset = "custom" + OutputUpdateRequestElasticsearchPresetLatency OutputUpdateRequestElasticsearchPreset = "latency" + OutputUpdateRequestElasticsearchPresetScale OutputUpdateRequestElasticsearchPreset = "scale" + OutputUpdateRequestElasticsearchPresetThroughput OutputUpdateRequestElasticsearchPreset = "throughput" +) + // Defines values for OutputUpdateRequestElasticsearchType. const ( OutputUpdateRequestElasticsearchTypeElasticsearch OutputUpdateRequestElasticsearchType = "elasticsearch" @@ -181,40 +204,54 @@ const ( UpdatePackagePolicyParamsFormatSimplified UpdatePackagePolicyParamsFormat = "simplified" ) -// GlobalDataTag defines the structure for each tag in GlobalDataTags. -type GlobalDataTag struct { - Name string `json:"name"` - Value interface{} `json:"value"` // Value can be either string or number -} - // AgentPolicy defines model for agent_policy. type AgentPolicy struct { - AgentFeatures *[]struct { + // AdvancedSettings Advanced settings stored in the agent policy, e.g. agent_limits_go_max_procs + AdvancedSettings *map[string]interface{} `json:"advanced_settings"` + AgentFeatures *[]struct { Enabled bool `json:"enabled"` Name string `json:"name"` } `json:"agent_features,omitempty"` - Agents *float32 `json:"agents,omitempty"` - DataOutputId *string `json:"data_output_id"` - Description *string `json:"description,omitempty"` - DownloadSourceId *string `json:"download_source_id"` - FleetServerHostId *string `json:"fleet_server_host_id"` - Id string `json:"id"` - InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` - GlobalDataTags []GlobalDataTag `json:"global_data_tags"` + Agents *float32 `json:"agents,omitempty"` + DataOutputId *string `json:"data_output_id"` + Description *string `json:"description,omitempty"` + DownloadSourceId *string `json:"download_source_id"` + FleetServerHostId *string `json:"fleet_server_host_id"` + GlobalDataTags *[]map[string]AgentPolicy_GlobalDataTags_AdditionalProperties `json:"global_data_tags,omitempty"` + Id string `json:"id"` + InactivityTimeout *int `json:"inactivity_timeout,omitempty"` // IsProtected Indicates whether the agent policy has tamper protection enabled. Default false. - IsProtected *bool `json:"is_protected,omitempty"` - MonitoringEnabled *[]AgentPolicyMonitoringEnabled `json:"monitoring_enabled,omitempty"` - MonitoringOutputId *string `json:"monitoring_output_id"` - Name string `json:"name"` - Namespace string `json:"namespace"` + IsProtected *bool `json:"is_protected,omitempty"` + + // KeepMonitoringAlive When set to true, monitoring will be enabled but logs/metrics collection will be disabled + KeepMonitoringAlive *bool `json:"keep_monitoring_alive"` + MonitoringEnabled *[]AgentPolicyMonitoringEnabled `json:"monitoring_enabled,omitempty"` + MonitoringOutputId *string `json:"monitoring_output_id"` + Name string `json:"name"` + Namespace string `json:"namespace"` // Overrides Override settings that are defined in the agent policy. Input settings cannot be overridden. The override option should be used only in unusual circumstances and not as a routine procedure. - Overrides *map[string]interface{} `json:"overrides"` - Revision *float32 `json:"revision,omitempty"` - UnenrollTimeout *float32 `json:"unenroll_timeout,omitempty"` - UpdatedBy *string `json:"updated_by,omitempty"` - UpdatedOn *time.Time `json:"updated_on,omitempty"` + Overrides *map[string]interface{} `json:"overrides"` + Revision *float32 `json:"revision,omitempty"` + + // SupportsAgentless Indicates whether the agent policy supports agentless integrations. Only allowed in a serverless environment. + SupportsAgentless *bool `json:"supports_agentless,omitempty"` + UnenrollTimeout *int `json:"unenroll_timeout,omitempty"` + UnprivilegedAgents *float32 `json:"unprivileged_agents,omitempty"` + UpdatedBy *string `json:"updated_by,omitempty"` + UpdatedOn *time.Time `json:"updated_on,omitempty"` +} + +// AgentPolicyGlobalDataTags0 defines model for . +type AgentPolicyGlobalDataTags0 = string + +// AgentPolicyGlobalDataTags1 defines model for . +type AgentPolicyGlobalDataTags1 = float32 + +// AgentPolicy_GlobalDataTags_AdditionalProperties defines model for agent_policy.global_data_tags.AdditionalProperties. +type AgentPolicy_GlobalDataTags_AdditionalProperties struct { + union json.RawMessage } // AgentPolicyMonitoringEnabled defines model for AgentPolicy.MonitoringEnabled. @@ -226,19 +263,33 @@ type AgentPolicyCreateRequest struct { Enabled bool `json:"enabled"` Name string `json:"name"` } `json:"agent_features,omitempty"` - DataOutputId *string `json:"data_output_id"` - Description *string `json:"description,omitempty"` - DownloadSourceId *string `json:"download_source_id"` - FleetServerHostId *string `json:"fleet_server_host_id"` - Id *string `json:"id,omitempty"` - InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` - GlobalDataTags []GlobalDataTag `json:"global_data_tags"` - MonitoringOutputId *string `json:"monitoring_output_id"` - IsProtected *bool `json:"is_protected,omitempty"` - MonitoringEnabled *[]AgentPolicyCreateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` - Name string `json:"name"` - Namespace string `json:"namespace"` - UnenrollTimeout *float32 `json:"unenroll_timeout,omitempty"` + DataOutputId *string `json:"data_output_id"` + Description *string `json:"description,omitempty"` + DownloadSourceId *string `json:"download_source_id"` + FleetServerHostId *string `json:"fleet_server_host_id"` + + // Force Force agent policy creation even if packages are not verified. + Force *bool `json:"force,omitempty"` + GlobalDataTags *[]map[string]AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties `json:"global_data_tags,omitempty"` + Id *string `json:"id,omitempty"` + InactivityTimeout *int `json:"inactivity_timeout,omitempty"` + IsProtected *bool `json:"is_protected,omitempty"` + MonitoringEnabled *[]AgentPolicyCreateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` + MonitoringOutputId *string `json:"monitoring_output_id"` + Name string `json:"name"` + Namespace string `json:"namespace"` + UnenrollTimeout *int `json:"unenroll_timeout,omitempty"` +} + +// AgentPolicyCreateRequestGlobalDataTags0 defines model for . +type AgentPolicyCreateRequestGlobalDataTags0 = string + +// AgentPolicyCreateRequestGlobalDataTags1 defines model for . +type AgentPolicyCreateRequestGlobalDataTags1 = float32 + +// AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties defines model for agent_policy_create_request.global_data_tags.AdditionalProperties. +type AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties struct { + union json.RawMessage } // AgentPolicyCreateRequestMonitoringEnabled defines model for AgentPolicyCreateRequest.MonitoringEnabled. @@ -250,18 +301,20 @@ type AgentPolicyUpdateRequest struct { Enabled bool `json:"enabled"` Name string `json:"name"` } `json:"agent_features,omitempty"` - DataOutputId *string `json:"data_output_id"` - Description *string `json:"description,omitempty"` - DownloadSourceId *string `json:"download_source_id"` - FleetServerHostId *string `json:"fleet_server_host_id"` - InactivityTimeout *float32 `json:"inactivity_timeout,omitempty"` - GlobalDataTags []GlobalDataTag `json:"global_data_tags"` + DataOutputId *string `json:"data_output_id"` + Description *string `json:"description,omitempty"` + DownloadSourceId *string `json:"download_source_id"` + FleetServerHostId *string `json:"fleet_server_host_id"` + + // Force Force agent policy creation even if packages are not verified. + Force *bool `json:"force,omitempty"` + InactivityTimeout *int `json:"inactivity_timeout,omitempty"` IsProtected *bool `json:"is_protected,omitempty"` MonitoringEnabled *[]AgentPolicyUpdateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` MonitoringOutputId *string `json:"monitoring_output_id"` Name string `json:"name"` Namespace string `json:"namespace"` - UnenrollTimeout *float32 `json:"unenroll_timeout,omitempty"` + UnenrollTimeout *int `json:"unenroll_timeout,omitempty"` } // AgentPolicyUpdateRequestMonitoringEnabled defines model for AgentPolicyUpdateRequest.MonitoringEnabled. @@ -286,8 +339,10 @@ type FleetServerHost struct { HostUrls []string `json:"host_urls"` Id string `json:"id"` IsDefault bool `json:"is_default"` + IsInternal *bool `json:"is_internal,omitempty"` IsPreconfigured bool `json:"is_preconfigured"` Name *string `json:"name,omitempty"` + ProxyId *string `json:"proxy_id,omitempty"` } // GetPackagesResponse defines model for get_packages_response. @@ -308,10 +363,13 @@ type NewPackagePolicy struct { Name string `json:"name"` Namespace *string `json:"namespace,omitempty"` // Deprecated: - OutputId *string `json:"output_id,omitempty"` - Package *PackagePolicyPackageInfo `json:"package,omitempty"` - PolicyId *string `json:"policy_id,omitempty"` - Vars *map[string]interface{} `json:"vars,omitempty"` + OutputId *string `json:"output_id,omitempty"` + Overrides *map[string]interface{} `json:"overrides,omitempty"` + Package *PackagePolicyPackageInfo `json:"package,omitempty"` + // Deprecated: + PolicyId *string `json:"policy_id,omitempty"` + PolicyIds *[]string `json:"policy_ids,omitempty"` + Vars *map[string]interface{} `json:"vars,omitempty"` } // OutputCreateRequest defines model for output_create_request. @@ -321,16 +379,18 @@ type OutputCreateRequest struct { // OutputCreateRequestElasticsearch defines model for output_create_request_elasticsearch. type OutputCreateRequestElasticsearch struct { - CaSha256 *string `json:"ca_sha256,omitempty"` - CaTrustedFingerprint *string `json:"ca_trusted_fingerprint,omitempty"` - Config *map[string]interface{} `json:"config,omitempty"` - ConfigYaml *string `json:"config_yaml,omitempty"` - Hosts *[]string `json:"hosts,omitempty"` - Id *string `json:"id,omitempty"` - IsDefault *bool `json:"is_default,omitempty"` - IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` - Name string `json:"name"` - ProxyId *string `json:"proxy_id,omitempty"` + CaSha256 *string `json:"ca_sha256,omitempty"` + CaTrustedFingerprint *string `json:"ca_trusted_fingerprint,omitempty"` + Config *map[string]interface{} `json:"config,omitempty"` + ConfigYaml *string `json:"config_yaml,omitempty"` + Hosts *[]string `json:"hosts,omitempty"` + Id *string `json:"id,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` + Name string `json:"name"` + Preset *OutputCreateRequestElasticsearchPreset `json:"preset,omitempty"` + ProxyId *string `json:"proxy_id,omitempty"` Shipper *struct { CompressionLevel *float32 `json:"compression_level,omitempty"` DiskQueueCompressionEnabled *bool `json:"disk_queue_compression_enabled,omitempty"` @@ -348,6 +408,9 @@ type OutputCreateRequestElasticsearch struct { Type OutputCreateRequestElasticsearchType `json:"type"` } +// OutputCreateRequestElasticsearchPreset defines model for OutputCreateRequestElasticsearch.Preset. +type OutputCreateRequestElasticsearchPreset string + // OutputCreateRequestElasticsearchType defines model for OutputCreateRequestElasticsearch.Type. type OutputCreateRequestElasticsearchType string @@ -371,6 +434,7 @@ type OutputCreateRequestKafka struct { Id *string `json:"id,omitempty"` IsDefault *bool `json:"is_default,omitempty"` IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` Key *string `json:"key,omitempty"` Name string `json:"name"` Partition *string `json:"partition,omitempty"` @@ -386,6 +450,12 @@ type OutputCreateRequestKafka struct { Sasl *struct { Mechanism *string `json:"mechanism,omitempty"` } `json:"sasl,omitempty"` + Secrets *struct { + Password *string `json:"password,omitempty"` + Ssl *struct { + Key *string `json:"key,omitempty"` + } `json:"ssl,omitempty"` + } `json:"secrets,omitempty"` Shipper *struct { CompressionLevel *float32 `json:"compression_level,omitempty"` DiskQueueCompressionEnabled *bool `json:"disk_queue_compression_enabled,omitempty"` @@ -402,9 +472,16 @@ type OutputCreateRequestKafka struct { VerificationMode *OutputCreateRequestKafkaSslVerificationMode `json:"verification_mode,omitempty"` } `json:"ssl,omitempty"` Timeout *float32 `json:"timeout,omitempty"` - Topics []struct { + Topic *string `json:"topic,omitempty"` + + // Topics Use topic instead. + // Deprecated: + Topics []struct { Topic *string `json:"topic,omitempty"` - When *struct { + + // When Deprecated, kafka output do not support conditionnal topics anymore. + // Deprecated: + When *struct { Condition *string `json:"condition,omitempty"` Type *string `json:"type,omitempty"` } `json:"when,omitempty"` @@ -433,9 +510,15 @@ type OutputCreateRequestLogstash struct { Id *string `json:"id,omitempty"` IsDefault *bool `json:"is_default,omitempty"` IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` Name string `json:"name"` ProxyId *string `json:"proxy_id,omitempty"` - Shipper *struct { + Secrets *struct { + Ssl *struct { + Key *string `json:"key,omitempty"` + } `json:"ssl,omitempty"` + } `json:"secrets,omitempty"` + Shipper *struct { CompressionLevel *float32 `json:"compression_level,omitempty"` DiskQueueCompressionEnabled *bool `json:"disk_queue_compression_enabled,omitempty"` DiskQueueEnabled *bool `json:"disk_queue_enabled,omitempty"` @@ -455,6 +538,24 @@ type OutputCreateRequestLogstash struct { // OutputCreateRequestLogstashType defines model for OutputCreateRequestLogstash.Type. type OutputCreateRequestLogstashType string +// OutputCreateRequestRemoteElasticsearch defines model for output_create_request_remote_elasticsearch. +type OutputCreateRequestRemoteElasticsearch struct { + Hosts *[]string `json:"hosts,omitempty"` + Id *string `json:"id,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` + Name string `json:"name"` + Secrets *struct { + ServiceToken *string `json:"service_token,omitempty"` + } `json:"secrets,omitempty"` + ServiceToken *string `json:"service_token,omitempty"` + Type OutputCreateRequestRemoteElasticsearchType `json:"type"` +} + +// OutputCreateRequestRemoteElasticsearchType defines model for OutputCreateRequestRemoteElasticsearch.Type. +type OutputCreateRequestRemoteElasticsearchType string + // OutputUpdateRequest defines model for output_update_request. type OutputUpdateRequest struct { union json.RawMessage @@ -462,16 +563,18 @@ type OutputUpdateRequest struct { // OutputUpdateRequestElasticsearch defines model for output_update_request_elasticsearch. type OutputUpdateRequestElasticsearch struct { - CaSha256 *string `json:"ca_sha256,omitempty"` - CaTrustedFingerprint *string `json:"ca_trusted_fingerprint,omitempty"` - Config *map[string]interface{} `json:"config,omitempty"` - ConfigYaml *string `json:"config_yaml,omitempty"` - Hosts []string `json:"hosts"` - Id *string `json:"id,omitempty"` - IsDefault *bool `json:"is_default,omitempty"` - IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` - Name string `json:"name"` - ProxyId *string `json:"proxy_id,omitempty"` + CaSha256 *string `json:"ca_sha256,omitempty"` + CaTrustedFingerprint *string `json:"ca_trusted_fingerprint,omitempty"` + Config *map[string]interface{} `json:"config,omitempty"` + ConfigYaml *string `json:"config_yaml,omitempty"` + Hosts []string `json:"hosts"` + Id *string `json:"id,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` + Name string `json:"name"` + Preset *OutputUpdateRequestElasticsearchPreset `json:"preset,omitempty"` + ProxyId *string `json:"proxy_id,omitempty"` Shipper *struct { CompressionLevel *float32 `json:"compression_level,omitempty"` DiskQueueCompressionEnabled *bool `json:"disk_queue_compression_enabled,omitempty"` @@ -489,6 +592,9 @@ type OutputUpdateRequestElasticsearch struct { Type OutputUpdateRequestElasticsearchType `json:"type"` } +// OutputUpdateRequestElasticsearchPreset defines model for OutputUpdateRequestElasticsearch.Preset. +type OutputUpdateRequestElasticsearchPreset string + // OutputUpdateRequestElasticsearchType defines model for OutputUpdateRequestElasticsearch.Type. type OutputUpdateRequestElasticsearchType string @@ -512,6 +618,7 @@ type OutputUpdateRequestKafka struct { Id *string `json:"id,omitempty"` IsDefault *bool `json:"is_default,omitempty"` IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` Key *string `json:"key,omitempty"` Name string `json:"name"` Partition *string `json:"partition,omitempty"` @@ -543,9 +650,16 @@ type OutputUpdateRequestKafka struct { VerificationMode *OutputUpdateRequestKafkaSslVerificationMode `json:"verification_mode,omitempty"` } `json:"ssl,omitempty"` Timeout *float32 `json:"timeout,omitempty"` - Topics *[]struct { + Topic *string `json:"topic,omitempty"` + + // Topics Use topic instead. + // Deprecated: + Topics *[]struct { Topic *string `json:"topic,omitempty"` - When *struct { + + // When Deprecated, kafka output do not support conditionnal topics anymore. + // Deprecated: + When *struct { Condition *string `json:"condition,omitempty"` Type *string `json:"type,omitempty"` } `json:"when,omitempty"` @@ -574,6 +688,7 @@ type OutputUpdateRequestLogstash struct { Id *string `json:"id,omitempty"` IsDefault *bool `json:"is_default,omitempty"` IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` Name string `json:"name"` ProxyId *string `json:"proxy_id,omitempty"` Shipper *struct { @@ -678,11 +793,14 @@ type PackagePolicy struct { Name string `json:"name"` Namespace *string `json:"namespace,omitempty"` // Deprecated: - OutputId *string `json:"output_id,omitempty"` - Package *PackagePolicyPackageInfo `json:"package,omitempty"` - PolicyId *string `json:"policy_id,omitempty"` - Revision float32 `json:"revision"` - Vars *map[string]interface{} `json:"vars,omitempty"` + OutputId *string `json:"output_id,omitempty"` + Overrides *map[string]interface{} `json:"overrides,omitempty"` + Package *PackagePolicyPackageInfo `json:"package,omitempty"` + // Deprecated: + PolicyId *string `json:"policy_id,omitempty"` + PolicyIds *[]string `json:"policy_ids,omitempty"` + Revision float32 `json:"revision"` + Vars *map[string]interface{} `json:"vars,omitempty"` } // PackagePolicyInput defines model for package_policy_input. @@ -697,9 +815,10 @@ type PackagePolicyInput struct { // PackagePolicyPackageInfo defines model for package_policy_package_info. type PackagePolicyPackageInfo struct { - Name string `json:"name"` - Title *string `json:"title,omitempty"` - Version string `json:"version"` + Name string `json:"name"` + RequiresRoot *bool `json:"requires_root,omitempty"` + Title *string `json:"title,omitempty"` + Version string `json:"version"` } // PackagePolicyRequest defines model for package_policy_request. @@ -719,9 +838,14 @@ type PackagePolicyRequest struct { // Name Package policy name (should be unique) Name string `json:"name"` - // Namespace namespace by default "default" + // Namespace The package policy namespace. Leave blank to inherit the agent policy's namespace. Namespace *string `json:"namespace,omitempty"` - Package struct { + + // Overrides Override settings that are defined in the package policy. The override option should be used only in unusual circumstances and not as a routine procedure. + Overrides *struct { + Inputs *map[string]interface{} `json:"inputs,omitempty"` + } `json:"overrides"` + Package struct { // Name Package name Name string `json:"name"` @@ -730,7 +854,11 @@ type PackagePolicyRequest struct { } `json:"package"` // PolicyId Agent policy ID where that package policy will be added - PolicyId string `json:"policy_id"` + // Deprecated: + PolicyId *string `json:"policy_id,omitempty"` + + // PolicyIds Agent policy IDs where that package policy will be added + PolicyIds *[]string `json:"policy_ids,omitempty"` // Vars Package root level variable (see integration documentation for more information) Vars *map[string]interface{} `json:"vars,omitempty"` @@ -787,6 +915,9 @@ type Error struct { // DeleteAgentPolicyJSONBody defines parameters for DeleteAgentPolicy. type DeleteAgentPolicyJSONBody struct { AgentPolicyId string `json:"agentPolicyId"` + + // Force bypass validation checks that can prevent agent policy deletion + Force *bool `json:"force,omitempty"` } // ListAllPackagesParams defines parameters for ListAllPackages. @@ -807,6 +938,9 @@ type DeletePackageJSONBody struct { // DeletePackageParams defines parameters for DeletePackage. type DeletePackageParams struct { + // Force delete package even if policies used by agents + Force *bool `form:"force,omitempty" json:"force,omitempty"` + // IgnoreUnverified Ignore if the package is fails signature verification IgnoreUnverified *bool `form:"ignoreUnverified,omitempty" json:"ignoreUnverified,omitempty"` @@ -837,6 +971,12 @@ type InstallPackageJSONBody struct { // InstallPackageParams defines parameters for InstallPackage. type InstallPackageParams struct { + // IgnoreMappingUpdateErrors avoid erroring out on unexpected mapping update errors + IgnoreMappingUpdateErrors *bool `form:"ignoreMappingUpdateErrors,omitempty" json:"ignoreMappingUpdateErrors,omitempty"` + + // SkipDataStreamRollover Skip data stream rollover during index template mapping or settings update + SkipDataStreamRollover *bool `form:"skipDataStreamRollover,omitempty" json:"skipDataStreamRollover,omitempty"` + // IgnoreUnverified Ignore if the package is fails signature verification IgnoreUnverified *bool `form:"ignoreUnverified,omitempty" json:"ignoreUnverified,omitempty"` @@ -866,17 +1006,25 @@ type UpdatePackageParams struct { // PostFleetServerHostsJSONBody defines parameters for PostFleetServerHosts. type PostFleetServerHostsJSONBody struct { - HostUrls []string `json:"host_urls"` - Id *string `json:"id,omitempty"` - IsDefault *bool `json:"is_default,omitempty"` - Name string `json:"name"` + HostUrls []string `json:"host_urls"` + Id *string `json:"id,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` + Name string `json:"name"` + + // ProxyId The ID of the proxy to use for this fleet server host. See the proxies API for more information. + ProxyId *string `json:"proxy_id,omitempty"` } // UpdateFleetServerHostsJSONBody defines parameters for UpdateFleetServerHosts. type UpdateFleetServerHostsJSONBody struct { - HostUrls *[]string `json:"host_urls,omitempty"` - IsDefault *bool `json:"is_default,omitempty"` - Name *string `json:"name,omitempty"` + HostUrls *[]string `json:"host_urls,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + IsInternal *bool `json:"is_internal,omitempty"` + Name *string `json:"name,omitempty"` + + // ProxyId The ID of the proxy to use for this fleet server host. See the proxies API for more information. + ProxyId *string `json:"proxy_id"` } // CreatePackagePolicyParams defines parameters for CreatePackagePolicy. @@ -947,6 +1095,130 @@ type CreatePackagePolicyJSONRequestBody = PackagePolicyRequest // UpdatePackagePolicyJSONRequestBody defines body for UpdatePackagePolicy for application/json ContentType. type UpdatePackagePolicyJSONRequestBody = PackagePolicyRequest +// AsAgentPolicyGlobalDataTags0 returns the union data inside the AgentPolicy_GlobalDataTags_AdditionalProperties as a AgentPolicyGlobalDataTags0 +func (t AgentPolicy_GlobalDataTags_AdditionalProperties) AsAgentPolicyGlobalDataTags0() (AgentPolicyGlobalDataTags0, error) { + var body AgentPolicyGlobalDataTags0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentPolicyGlobalDataTags0 overwrites any union data inside the AgentPolicy_GlobalDataTags_AdditionalProperties as the provided AgentPolicyGlobalDataTags0 +func (t *AgentPolicy_GlobalDataTags_AdditionalProperties) FromAgentPolicyGlobalDataTags0(v AgentPolicyGlobalDataTags0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentPolicyGlobalDataTags0 performs a merge with any union data inside the AgentPolicy_GlobalDataTags_AdditionalProperties, using the provided AgentPolicyGlobalDataTags0 +func (t *AgentPolicy_GlobalDataTags_AdditionalProperties) MergeAgentPolicyGlobalDataTags0(v AgentPolicyGlobalDataTags0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAgentPolicyGlobalDataTags1 returns the union data inside the AgentPolicy_GlobalDataTags_AdditionalProperties as a AgentPolicyGlobalDataTags1 +func (t AgentPolicy_GlobalDataTags_AdditionalProperties) AsAgentPolicyGlobalDataTags1() (AgentPolicyGlobalDataTags1, error) { + var body AgentPolicyGlobalDataTags1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentPolicyGlobalDataTags1 overwrites any union data inside the AgentPolicy_GlobalDataTags_AdditionalProperties as the provided AgentPolicyGlobalDataTags1 +func (t *AgentPolicy_GlobalDataTags_AdditionalProperties) FromAgentPolicyGlobalDataTags1(v AgentPolicyGlobalDataTags1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentPolicyGlobalDataTags1 performs a merge with any union data inside the AgentPolicy_GlobalDataTags_AdditionalProperties, using the provided AgentPolicyGlobalDataTags1 +func (t *AgentPolicy_GlobalDataTags_AdditionalProperties) MergeAgentPolicyGlobalDataTags1(v AgentPolicyGlobalDataTags1) 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 AgentPolicy_GlobalDataTags_AdditionalProperties) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *AgentPolicy_GlobalDataTags_AdditionalProperties) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsAgentPolicyCreateRequestGlobalDataTags0 returns the union data inside the AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties as a AgentPolicyCreateRequestGlobalDataTags0 +func (t AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) AsAgentPolicyCreateRequestGlobalDataTags0() (AgentPolicyCreateRequestGlobalDataTags0, error) { + var body AgentPolicyCreateRequestGlobalDataTags0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentPolicyCreateRequestGlobalDataTags0 overwrites any union data inside the AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties as the provided AgentPolicyCreateRequestGlobalDataTags0 +func (t *AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) FromAgentPolicyCreateRequestGlobalDataTags0(v AgentPolicyCreateRequestGlobalDataTags0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentPolicyCreateRequestGlobalDataTags0 performs a merge with any union data inside the AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties, using the provided AgentPolicyCreateRequestGlobalDataTags0 +func (t *AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) MergeAgentPolicyCreateRequestGlobalDataTags0(v AgentPolicyCreateRequestGlobalDataTags0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAgentPolicyCreateRequestGlobalDataTags1 returns the union data inside the AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties as a AgentPolicyCreateRequestGlobalDataTags1 +func (t AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) AsAgentPolicyCreateRequestGlobalDataTags1() (AgentPolicyCreateRequestGlobalDataTags1, error) { + var body AgentPolicyCreateRequestGlobalDataTags1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentPolicyCreateRequestGlobalDataTags1 overwrites any union data inside the AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties as the provided AgentPolicyCreateRequestGlobalDataTags1 +func (t *AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) FromAgentPolicyCreateRequestGlobalDataTags1(v AgentPolicyCreateRequestGlobalDataTags1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentPolicyCreateRequestGlobalDataTags1 performs a merge with any union data inside the AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties, using the provided AgentPolicyCreateRequestGlobalDataTags1 +func (t *AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) MergeAgentPolicyCreateRequestGlobalDataTags1(v AgentPolicyCreateRequestGlobalDataTags1) 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 AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + // AsOutputCreateRequestElasticsearch returns the union data inside the OutputCreateRequest as a OutputCreateRequestElasticsearch func (t OutputCreateRequest) AsOutputCreateRequestElasticsearch() (OutputCreateRequestElasticsearch, error) { var body OutputCreateRequestElasticsearch @@ -1031,6 +1303,34 @@ func (t *OutputCreateRequest) MergeOutputCreateRequestLogstash(v OutputCreateReq return err } +// AsOutputCreateRequestRemoteElasticsearch returns the union data inside the OutputCreateRequest as a OutputCreateRequestRemoteElasticsearch +func (t OutputCreateRequest) AsOutputCreateRequestRemoteElasticsearch() (OutputCreateRequestRemoteElasticsearch, error) { + var body OutputCreateRequestRemoteElasticsearch + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromOutputCreateRequestRemoteElasticsearch overwrites any union data inside the OutputCreateRequest as the provided OutputCreateRequestRemoteElasticsearch +func (t *OutputCreateRequest) FromOutputCreateRequestRemoteElasticsearch(v OutputCreateRequestRemoteElasticsearch) error { + v.Type = "remote_elasticsearch" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeOutputCreateRequestRemoteElasticsearch performs a merge with any union data inside the OutputCreateRequest, using the provided OutputCreateRequestRemoteElasticsearch +func (t *OutputCreateRequest) MergeOutputCreateRequestRemoteElasticsearch(v OutputCreateRequestRemoteElasticsearch) error { + v.Type = "remote_elasticsearch" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + func (t OutputCreateRequest) Discriminator() (string, error) { var discriminator struct { Discriminator string `json:"type"` @@ -1051,6 +1351,8 @@ func (t OutputCreateRequest) ValueByDiscriminator() (interface{}, error) { return t.AsOutputCreateRequestKafka() case "logstash": return t.AsOutputCreateRequestLogstash() + case "remote_elasticsearch": + return t.AsOutputCreateRequestRemoteElasticsearch() default: return nil, errors.New("unknown discriminator value: " + discriminator) } @@ -2151,6 +2453,22 @@ func NewDeletePackageRequestWithBody(server string, pkgName string, pkgVersion s if params != nil { queryValues := queryURL.Query() + if params.Force != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "force", runtime.ParamLocationQuery, *params.Force); 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.IgnoreUnverified != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ignoreUnverified", runtime.ParamLocationQuery, *params.IgnoreUnverified); err != nil { @@ -2354,6 +2672,38 @@ func NewInstallPackageRequestWithBody(server string, pkgName string, pkgVersion if params != nil { queryValues := queryURL.Query() + if params.IgnoreMappingUpdateErrors != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ignoreMappingUpdateErrors", runtime.ParamLocationQuery, *params.IgnoreMappingUpdateErrors); 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.SkipDataStreamRollover != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "skipDataStreamRollover", runtime.ParamLocationQuery, *params.SkipDataStreamRollover); 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.IgnoreUnverified != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ignoreUnverified", runtime.ParamLocationQuery, *params.IgnoreUnverified); err != nil { diff --git a/generated/fleet/getschema.go b/generated/fleet/getschema.go index dd49fa7e9..1eb9a728e 100644 --- a/generated/fleet/getschema.go +++ b/generated/fleet/getschema.go @@ -157,6 +157,7 @@ func transformOutputTypeRequired(schema *Schema) { "schemas.output_update_request_elasticsearch.required", "schemas.output_update_request_kafka.required", "schemas.output_update_request_logstash.required", + "schemas.output_create_request_remote_elasticsearch.required", } for _, v := range path { diff --git a/tools/fleet_gen.go b/tools/fleet_gen.go index d01d7493c..72e71abea 100644 --- a/tools/fleet_gen.go +++ b/tools/fleet_gen.go @@ -1,4 +1,4 @@ package tools -//go:generate go run ../generated/fleet/getschema.go -v v8.10.0 -o ../generated/fleet/fleet-filtered.json +//go:generate go run ../generated/fleet/getschema.go -v v8.15.0 -o ../generated/fleet/fleet-filtered.json //go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -package=fleet -generate=types,client -o ../generated/fleet/fleet.gen.go ../generated/fleet/fleet-filtered.json From d023e7ba93b3c86e2f78d5cb02119c7b629e333c Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Wed, 28 Aug 2024 17:50:54 +1000 Subject: [PATCH 08/11] POC for interacting with the generated types --- internal/fleet/agent_policy_resource.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index 075730341..acfa97be2 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -170,16 +170,20 @@ func resourceAgentPolicyCreate(ctx context.Context, d *schema.ResourceData, meta return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) } - globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) + gdt := []map[string]fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{} for key, value := range tagMap { - globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ - Name: key, - Value: value.(string), + name := fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{} + name.FromAgentPolicyCreateRequestGlobalDataTags0(key) + + val := fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{} + val.FromAgentPolicyCreateRequestGlobalDataTags0(value.(string)) + + gdt = append(gdt, map[string]fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{ + "name": name, + "value": val, }) } - req.GlobalDataTags = globalDataTags - } else { - req.GlobalDataTags = make([]fleetapi.GlobalDataTag, 0) // Ensure it's an empty array + req.GlobalDataTags = &gdt } policy, diags := fleet.CreateAgentPolicy(ctx, fleetClient, req) From b794328d1b141f0289e6e1c052623ab1cee2946b Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Sun, 1 Sep 2024 22:19:28 +1000 Subject: [PATCH 09/11] Regenerate, update implementation --- generated/fleet/fleet.gen.go | 90 +- internal/fleet/agent_policy_resource.go | 40 +- internal/fleet/integration_policy_resource.go | 5 +- tools/fleet-spec.json | 9458 +++++++++++++++++ tools/fleet_gen.go | 4 +- 5 files changed, 9576 insertions(+), 21 deletions(-) create mode 100644 tools/fleet-spec.json diff --git a/generated/fleet/fleet.gen.go b/generated/fleet/fleet.gen.go index 1460ba598..e8378f748 100644 --- a/generated/fleet/fleet.gen.go +++ b/generated/fleet/fleet.gen.go @@ -307,14 +307,26 @@ type AgentPolicyUpdateRequest struct { FleetServerHostId *string `json:"fleet_server_host_id"` // Force Force agent policy creation even if packages are not verified. - Force *bool `json:"force,omitempty"` - InactivityTimeout *int `json:"inactivity_timeout,omitempty"` - IsProtected *bool `json:"is_protected,omitempty"` - MonitoringEnabled *[]AgentPolicyUpdateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` - MonitoringOutputId *string `json:"monitoring_output_id"` - Name string `json:"name"` - Namespace string `json:"namespace"` - UnenrollTimeout *int `json:"unenroll_timeout,omitempty"` + Force *bool `json:"force,omitempty"` + GlobalDataTags *[]map[string]AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties `json:"global_data_tags,omitempty"` + InactivityTimeout *int `json:"inactivity_timeout,omitempty"` + IsProtected *bool `json:"is_protected,omitempty"` + MonitoringEnabled *[]AgentPolicyUpdateRequestMonitoringEnabled `json:"monitoring_enabled,omitempty"` + MonitoringOutputId *string `json:"monitoring_output_id"` + Name string `json:"name"` + Namespace string `json:"namespace"` + UnenrollTimeout *int `json:"unenroll_timeout,omitempty"` +} + +// AgentPolicyUpdateRequestGlobalDataTags0 defines model for . +type AgentPolicyUpdateRequestGlobalDataTags0 = string + +// AgentPolicyUpdateRequestGlobalDataTags1 defines model for . +type AgentPolicyUpdateRequestGlobalDataTags1 = float32 + +// AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties defines model for agent_policy_update_request.global_data_tags.AdditionalProperties. +type AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties struct { + union json.RawMessage } // AgentPolicyUpdateRequestMonitoringEnabled defines model for AgentPolicyUpdateRequest.MonitoringEnabled. @@ -1219,6 +1231,68 @@ func (t *AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties) Unmarshal return err } +// AsAgentPolicyUpdateRequestGlobalDataTags0 returns the union data inside the AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties as a AgentPolicyUpdateRequestGlobalDataTags0 +func (t AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) AsAgentPolicyUpdateRequestGlobalDataTags0() (AgentPolicyUpdateRequestGlobalDataTags0, error) { + var body AgentPolicyUpdateRequestGlobalDataTags0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentPolicyUpdateRequestGlobalDataTags0 overwrites any union data inside the AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties as the provided AgentPolicyUpdateRequestGlobalDataTags0 +func (t *AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) FromAgentPolicyUpdateRequestGlobalDataTags0(v AgentPolicyUpdateRequestGlobalDataTags0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentPolicyUpdateRequestGlobalDataTags0 performs a merge with any union data inside the AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties, using the provided AgentPolicyUpdateRequestGlobalDataTags0 +func (t *AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) MergeAgentPolicyUpdateRequestGlobalDataTags0(v AgentPolicyUpdateRequestGlobalDataTags0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAgentPolicyUpdateRequestGlobalDataTags1 returns the union data inside the AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties as a AgentPolicyUpdateRequestGlobalDataTags1 +func (t AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) AsAgentPolicyUpdateRequestGlobalDataTags1() (AgentPolicyUpdateRequestGlobalDataTags1, error) { + var body AgentPolicyUpdateRequestGlobalDataTags1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentPolicyUpdateRequestGlobalDataTags1 overwrites any union data inside the AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties as the provided AgentPolicyUpdateRequestGlobalDataTags1 +func (t *AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) FromAgentPolicyUpdateRequestGlobalDataTags1(v AgentPolicyUpdateRequestGlobalDataTags1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentPolicyUpdateRequestGlobalDataTags1 performs a merge with any union data inside the AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties, using the provided AgentPolicyUpdateRequestGlobalDataTags1 +func (t *AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) MergeAgentPolicyUpdateRequestGlobalDataTags1(v AgentPolicyUpdateRequestGlobalDataTags1) 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 AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + // AsOutputCreateRequestElasticsearch returns the union data inside the OutputCreateRequest as a OutputCreateRequestElasticsearch func (t OutputCreateRequest) AsOutputCreateRequestElasticsearch() (OutputCreateRequestElasticsearch, error) { var body OutputCreateRequestElasticsearch diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index acfa97be2..5feeb7c90 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -252,16 +252,27 @@ func resourceAgentPolicyUpdate(ctx context.Context, d *schema.ResourceData, meta return diag.FromErr(fmt.Errorf("'global_data_tags' is supported only for Elasticsearch v%s and above", minVersionGlobalDataTags.String())) } - globalDataTags := make([]fleetapi.GlobalDataTag, 0, len(tagMap)) - for key, value := range tagMap { - globalDataTags = append(globalDataTags, fleetapi.GlobalDataTag{ - Name: key, - Value: value.(string), + globalDataTags := []map[string]fleetapi.AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties{} + for key, val := range tagMap { + var name, value fleetapi.AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties + err := name.FromAgentPolicyUpdateRequestGlobalDataTags0(key) + if err != nil { + return diag.FromErr(err) + } + + err = value.FromAgentPolicyUpdateRequestGlobalDataTags0(val.(string)) + if err != nil { + return diag.FromErr(err) + } + + globalDataTags = append(globalDataTags, map[string]fleetapi.AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties{ + "name": name, + "value": value, }) } - req.GlobalDataTags = globalDataTags + req.GlobalDataTags = &globalDataTags } else { - req.GlobalDataTags = make([]fleetapi.GlobalDataTag, 0) // Ensure it's an empty array + req.GlobalDataTags = &[]map[string]fleetapi.AgentPolicyUpdateRequest_GlobalDataTags_AdditionalProperties{} // Ensure it's an empty array } _, diags = fleet.UpdateAgentPolicy(ctx, fleetClient, d.Id(), req) @@ -351,9 +362,18 @@ func resourceAgentPolicyRead(ctx context.Context, d *schema.ResourceData, meta i if agentPolicy.GlobalDataTags != nil { - globalDataTags := make(map[string]string, len(agentPolicy.GlobalDataTags)) - for _, tag := range agentPolicy.GlobalDataTags { - globalDataTags[tag.Name] = tag.Value.(string) + globalDataTags := make(map[string]string, len(*agentPolicy.GlobalDataTags)) + for _, tag := range *agentPolicy.GlobalDataTags { + name, err := tag["name"].AsAgentPolicyGlobalDataTags0() + if err != nil { + return diag.FromErr(err) + } + + value, err := tag["value"].AsAgentPolicyGlobalDataTags0() + if err != nil { + return diag.FromErr(err) + } + globalDataTags[name] = value } if err := d.Set("global_data_tags", globalDataTags); err != nil { diff --git a/internal/fleet/integration_policy_resource.go b/internal/fleet/integration_policy_resource.go index 86f2f7ea0..aaef24231 100644 --- a/internal/fleet/integration_policy_resource.go +++ b/internal/fleet/integration_policy_resource.go @@ -11,6 +11,7 @@ import ( fleetapi "github.com/elastic/terraform-provider-elasticstack/generated/fleet" "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" + "github.com/elastic/terraform-provider-elasticstack/internal/utils" ) func ResourceIntegrationPolicy() *schema.Resource { @@ -135,7 +136,7 @@ func resourceIntegrationPolicyCreate(ctx context.Context, d *schema.ResourceData } req := fleetapi.CreatePackagePolicyJSONRequestBody{ - PolicyId: d.Get("agent_policy_id").(string), + PolicyId: utils.Pointer(d.Get("agent_policy_id").(string)), Name: d.Get("name").(string), } req.Package.Name = d.Get("integration_name").(string) @@ -215,7 +216,7 @@ func resourceIntegrationPolicyUpdate(ctx context.Context, d *schema.ResourceData } req := fleetapi.UpdatePackagePolicyJSONRequestBody{ - PolicyId: d.Get("agent_policy_id").(string), + PolicyId: utils.Pointer(d.Get("agent_policy_id").(string)), Name: d.Get("name").(string), } req.Package.Name = d.Get("integration_name").(string) diff --git a/tools/fleet-spec.json b/tools/fleet-spec.json new file mode 100644 index 000000000..5611ab9de --- /dev/null +++ b/tools/fleet-spec.json @@ -0,0 +1,9458 @@ +{ + "openapi": "3.0.0", + "tags": [], + "info": { + "title": "Fleet", + "description": "OpenAPI schema for Fleet API endpoints", + "version": "0.2", + "contact": { + "name": "Fleet Team" + }, + "license": { + "name": "Elastic License 2.0", + "url": "https://www.elastic.co/licensing/elastic-license" + } + }, + "servers": [ + { + "url": "http://KIBANA_HOST:5601/api/fleet", + "description": "Public and supported Fleet API" + } + ], + "paths": { + "/health_check": { + "post": { + "summary": "Fleet Server health check", + "tags": [ + "Fleet internals" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string" + }, + "id": { + "type": "string", + "description": "Fleet Server host id" + }, + "host": { + "type": "string", + "deprecated": true + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "fleet-server-health-check", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "host": { + "type": "string", + "deprecated": true + } + }, + "required": [ + "id" + ] + } + } + } + } + } + }, + "/setup": { + "post": { + "summary": "Initiate Fleet setup", + "tags": [ + "Fleet internals" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/fleet_setup_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + } + }, + "operationId": "setup", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/settings": { + "get": { + "summary": "Get settings", + "tags": [ + "Fleet internals" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/fleet_settings_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-settings" + }, + "put": { + "summary": "Update settings", + "tags": [ + "Fleet internals" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "fleet_server_hosts": { + "type": "array", + "description": "Protocol and path must be the same for each URL", + "items": { + "type": "string" + } + }, + "has_seen_add_data_notice": { + "type": "boolean" + }, + "additional_yaml_config": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/fleet_settings_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "update-settings" + } + }, + "/settings/enrollment": { + "servers": [ + { + "url": "http://KIBANA_HOST:5601/internal/fleet", + "description": "Used for Fleet internals and not supported" + } + ], + "get": { + "summary": "Get enrollment settings", + "tags": [ + "Fleet internals" + ], + "parameters": [ + { + "in": "query", + "name": "agentPolicyId", + "required": false, + "schema": { + "type": "string" + }, + "description": "An agent policy ID to scope the enrollment settings to. For example, that policy's Fleet Server host, its proxy, download location, etc. If not provided, the default Fleet Server policy is used (if any)." + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/fleet_settings_enrollment_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-enrollment-settings" + } + }, + "/service-tokens": { + "post": { + "summary": "Create service token", + "tags": [ + "Service tokens" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "generate-service-token-deprecated", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "deprecated": true + } + }, + "/service_tokens": { + "post": { + "summary": "Create service token", + "tags": [ + "Service tokens" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "generate-service-token", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/epm/verification_key_id": { + "get": { + "summary": "Get package signature verification key ID", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "body": { + "type": "object", + "properties": { + "id": { + "type": "string", + "nullable": true, + "description": "the key ID of the GPG key used to verify package signatures" + } + } + }, + "statusCode": { + "type": "number" + }, + "headers": { + "type": "object" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "packages-get-verification-key-id" + }, + "parameters": [] + }, + "/epm/bulk_assets": { + "post": { + "summary": "Bulk get assets", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_bulk_assets_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-get-assets", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "assetIds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "id": { + "type": "string" + } + } + }, + "description": "list of items necessary to fetch assets" + } + }, + "required": [ + "assetIds" + ] + } + } + } + } + } + }, + "/epm/categories": { + "get": { + "summary": "List package categories", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_categories_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-package-categories" + }, + "parameters": [ + { + "in": "query", + "name": "prerelease", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Whether to include prerelease packages in categories count (e.g. beta, rc, preview)" + }, + { + "in": "query", + "name": "experimental", + "deprecated": true, + "schema": { + "type": "boolean", + "default": false + } + }, + { + "in": "query", + "name": "include_policy_templates", + "schema": { + "type": "boolean", + "default": false + } + } + ] + }, + "/epm/packages/limited": { + "get": { + "summary": "Get limited package list", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "list-limited-packages" + }, + "parameters": [] + }, + "/epm/packages": { + "get": { + "summary": "List packages", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_packages_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "list-all-packages", + "parameters": [ + { + "in": "query", + "name": "excludeInstallStatus", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Whether to exclude the install status of each package. Enabling this option will opt in to caching for the response via `cache-control` headers. If you don't need up-to-date installation info for a package, and are querying for a list of available packages, providing this flag can improve performance substantially." + }, + { + "in": "query", + "name": "prerelease", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" + }, + { + "in": "query", + "name": "experimental", + "deprecated": true, + "schema": { + "type": "boolean", + "default": false + } + }, + { + "in": "query", + "name": "category", + "schema": { + "type": "string" + } + } + ] + }, + "post": { + "summary": "Install by package by direct upload", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "oneOf": [ + { + "$ref": "#/components/schemas/kibana_saved_object_type" + }, + { + "$ref": "#/components/schemas/elasticsearch_asset_type" + } + ] + } + }, + "required": [ + "id", + "type" + ] + } + }, + "_meta": { + "type": "object", + "properties": { + "install_source": { + "type": "string", + "enum": [ + "upload", + "registry", + "bundled" + ] + } + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + }, + "429": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "install-package-by-upload", + "description": "", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "in": "query", + "name": "ignoreMappingUpdateErrors", + "schema": { + "type": "boolean", + "default": false + }, + "description": "avoid erroring out on unexpected mapping update errors" + }, + { + "in": "query", + "name": "skipDataStreamRollover", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Skip data stream rollover during index template mapping or settings update" + } + ], + "requestBody": { + "content": { + "application/zip": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "application/gzip": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + }, + "/epm/packages/_bulk": { + "post": { + "summary": "Bulk install packages", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/bulk_install_packages_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-install-packages", + "parameters": [ + { + "in": "query", + "name": "prerelease", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "packages": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string", + "description": "package name" + }, + { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "package name" + }, + "version": { + "type": "string", + "description": "package version" + } + } + } + ] + }, + "description": "list of packages to install" + }, + "force": { + "type": "boolean", + "description": "force install to ignore package verification errors" + } + }, + "required": [ + "packages" + ] + } + } + } + } + } + }, + "/epm/packages/{pkgkey}": { + "get": { + "summary": "Get package", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "allOf": [ + { + "properties": { + "response": { + "$ref": "#/components/schemas/package_info" + } + } + }, + { + "properties": { + "status": { + "type": "string", + "enum": [ + "installed", + "installing", + "install_failed", + "not_installed" + ] + }, + "savedObject": { + "type": "string" + } + }, + "required": [ + "status", + "savedObject" + ] + } + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-package-deprecated", + "security": [ + { + "basicAuth": [] + } + ], + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "pkgkey", + "in": "path", + "required": true + }, + { + "in": "query", + "name": "prerelease", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" + } + ], + "deprecated": true + }, + "post": { + "summary": "Install package", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "response": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "oneOf": [ + { + "$ref": "#/components/schemas/kibana_saved_object_type" + }, + { + "$ref": "#/components/schemas/elasticsearch_asset_type" + } + ] + } + }, + "required": [ + "id", + "type" + ] + } + } + }, + "required": [ + "response" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "install-package-deprecated", + "description": "", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "schema": { + "type": "string" + }, + "name": "pkgkey", + "in": "path", + "required": true + }, + { + "in": "query", + "name": "ignoreMappingUpdateErrors", + "schema": { + "type": "boolean", + "default": false + }, + "description": "avoid erroring out on unexpected mapping update errors" + }, + { + "in": "query", + "name": "skipDataStreamRollover", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Skip data stream rollover during index template mapping or settings update" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "force": { + "type": "boolean" + } + } + } + } + } + }, + "deprecated": true + }, + "delete": { + "summary": "Delete ackage", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "response": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "oneOf": [ + { + "$ref": "#/components/schemas/kibana_saved_object_type" + }, + { + "$ref": "#/components/schemas/elasticsearch_asset_type" + } + ] + } + }, + "required": [ + "id", + "type" + ] + } + } + }, + "required": [ + "response" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "delete-package-deprecated", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "schema": { + "type": "string" + }, + "name": "pkgkey", + "in": "path", + "required": true + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "force": { + "type": "boolean" + } + } + } + } + } + }, + "deprecated": true + } + }, + "/epm/packages/{pkgName}/{pkgVersion}": { + "get": { + "summary": "Get package", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "allOf": [ + { + "properties": { + "item": { + "$ref": "#/components/schemas/package_info" + } + } + }, + { + "properties": { + "status": { + "type": "string", + "enum": [ + "installed", + "installing", + "install_failed", + "not_installed" + ] + }, + "savedObject": { + "type": "object", + "deprecated": true + }, + "latestVersion": { + "type": "string" + }, + "keepPoliciesUpToDate": { + "type": "boolean" + }, + "notice": { + "type": "string" + }, + "licensePath": { + "type": "string" + } + }, + "required": [ + "status", + "savedObject" + ] + } + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-package", + "security": [ + { + "basicAuth": [] + } + ] + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "pkgName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "pkgVersion", + "in": "path", + "required": true + }, + { + "schema": { + "type": "boolean" + }, + "name": "ignoreUnverified", + "description": "Ignore if the package is fails signature verification", + "in": "query" + }, + { + "schema": { + "type": "boolean" + }, + "name": "full", + "description": "Return all fields from the package manifest, not just those supported by the Elastic Package Registry", + "in": "query" + }, + { + "in": "query", + "name": "prerelease", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Whether to return prerelease versions of packages (e.g. beta, rc, preview)" + } + ], + "post": { + "summary": "Install package", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "oneOf": [ + { + "$ref": "#/components/schemas/kibana_saved_object_type" + }, + { + "$ref": "#/components/schemas/elasticsearch_asset_type" + } + ] + } + }, + "required": [ + "id", + "type" + ] + } + }, + "_meta": { + "type": "object", + "properties": { + "install_source": { + "type": "string", + "enum": [ + "registry", + "upload", + "bundled" + ] + } + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "install-package", + "description": "", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "in": "query", + "name": "ignoreMappingUpdateErrors", + "schema": { + "type": "boolean", + "default": false + }, + "description": "avoid erroring out on unexpected mapping update errors" + }, + { + "in": "query", + "name": "skipDataStreamRollover", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Skip data stream rollover during index template mapping or settings update" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "force": { + "type": "boolean" + }, + "ignore_constraints": { + "type": "boolean" + } + } + } + } + } + } + }, + "put": { + "summary": "Update package settings", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "oneOf": [ + { + "$ref": "#/components/schemas/kibana_saved_object_type" + }, + { + "$ref": "#/components/schemas/elasticsearch_asset_type" + } + ] + } + }, + "required": [ + "id", + "type" + ] + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "update-package", + "description": "", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "keepPoliciesUpToDate": { + "type": "boolean" + } + } + } + } + } + } + }, + "delete": { + "summary": "Delete package", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "oneOf": [ + { + "$ref": "#/components/schemas/kibana_saved_object_type" + }, + { + "$ref": "#/components/schemas/elasticsearch_asset_type" + } + ] + } + }, + "required": [ + "id", + "type" + ] + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "delete-package", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "schema": { + "type": "boolean" + }, + "name": "force", + "description": "delete package even if policies used by agents", + "in": "query" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "deprecated": true, + "properties": { + "force": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "/epm/packages/{pkgName}/{pkgVersion}/transforms/authorize": { + "post": { + "summary": "Authorize transforms", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "transformId": { + "type": "string" + }, + "success": { + "type": "boolean" + }, + "error": { + "type": "string" + } + }, + "required": [ + "transformId", + "error" + ] + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "reauthorize-transforms", + "description": "", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "schema": { + "type": "string" + }, + "name": "pkgName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "pkgVersion", + "in": "path", + "required": true + }, + { + "in": "query", + "name": "prerelease", + "schema": { + "type": "boolean", + "default": false + }, + "description": "Whether to include prerelease packages in categories count (e.g. beta, rc, preview)" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "transforms": { + "type": "array", + "items": { + "type": "object", + "properties": { + "transformId": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + }, + "/epm/packages/{pkgName}/{pkgVersion}/{filePath}": { + "get": { + "summary": "Get package file", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "body": { + "type": "object" + }, + "statusCode": { + "type": "number" + }, + "headers": { + "type": "object" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "packages-get-file" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "pkgName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "pkgVersion", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "filePath", + "in": "path", + "required": true + } + ] + }, + "/epm/packages/{pkgName}/stats": { + "get": { + "summary": "Get package stats", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "response": { + "$ref": "#/components/schemas/package_usage_stats" + } + }, + "required": [ + "response" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-package-stats", + "security": [ + { + "basicAuth": [] + } + ] + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "pkgName", + "in": "path", + "required": true + } + ] + }, + "/epm/templates/{pkgName}/{pkgVersion}/inputs": { + "get": { + "summary": "Get inputs template", + "tags": [ + "Elastic Package Manager (EPM)" + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-inputs-template", + "security": [ + { + "basicAuth": [] + } + ] + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "pkgName", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "pkgVersion", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string", + "enum": [ + "json", + "yaml", + "yml" + ] + }, + "name": "format", + "description": "Format of response - json or yaml", + "in": "query" + }, + { + "schema": { + "type": "boolean" + }, + "name": "prerelease", + "description": "Specify if version is prerelease", + "in": "query" + }, + { + "schema": { + "type": "boolean" + }, + "name": "ignoreUnverified", + "description": "Ignore if the package is fails signature verification", + "in": "query" + } + ] + }, + "/agents/setup": { + "get": { + "summary": "Get agent setup info", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/fleet_status_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agents-setup-status", + "security": [ + { + "basicAuth": [] + } + ] + }, + "post": { + "summary": "Initiate agent setup", + "tags": [ + "Agents" + ], + "operationId": "setup-agents", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/fleet_setup_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "admin_username": { + "type": "string" + }, + "admin_password": { + "type": "string" + } + }, + "required": [ + "admin_username", + "admin_password" + ] + } + } + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/agent-status": { + "get": { + "summary": "Get agent status summary", + "tags": [ + "Agent status" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer" + }, + "events": { + "type": "integer" + }, + "inactive": { + "type": "integer" + }, + "offline": { + "type": "integer" + }, + "online": { + "type": "integer" + }, + "other": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "updating": { + "type": "integer" + } + }, + "required": [ + "error", + "events", + "inactive", + "offline", + "online", + "other", + "total", + "updating" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agent-status-deprecated", + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "policyId", + "in": "query", + "required": false + } + ], + "deprecated": true + } + }, + "/agent_status": { + "get": { + "summary": "Get agent status summary", + "tags": [ + "Agent status" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer" + }, + "events": { + "type": "integer" + }, + "inactive": { + "type": "integer" + }, + "unenrolled": { + "type": "integer" + }, + "offline": { + "type": "integer" + }, + "online": { + "type": "integer" + }, + "other": { + "type": "integer" + }, + "total": { + "type": "integer", + "deprecated": true + }, + "updating": { + "type": "integer" + }, + "all": { + "type": "integer" + }, + "active": { + "type": "integer" + } + }, + "required": [ + "active", + "all", + "error", + "events", + "inactive", + "offline", + "online", + "other", + "total", + "updating" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agent-status", + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "policyId", + "in": "query", + "required": false + }, + { + "schema": { + "type": "string" + }, + "name": "kuery", + "in": "query", + "required": false, + "deprecated": true + } + ] + } + }, + "/agent_status/data": { + "get": { + "summary": "Get incoming agent data", + "tags": [ + "Agent status" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "data": { + "type": "boolean" + } + } + } + } + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agent-data", + "parameters": [ + { + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": "agentsIds", + "in": "query", + "required": true + } + ] + } + }, + "/agents": { + "get": { + "summary": "List agents", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_agents_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agents", + "parameters": [ + { + "$ref": "#/components/parameters/page_size" + }, + { + "$ref": "#/components/parameters/page_index" + }, + { + "$ref": "#/components/parameters/kuery" + }, + { + "$ref": "#/components/parameters/show_inactive" + }, + { + "$ref": "#/components/parameters/show_upgradeable" + }, + { + "$ref": "#/components/parameters/sort_field" + }, + { + "$ref": "#/components/parameters/sort_order" + }, + { + "$ref": "#/components/parameters/with_metrics" + }, + { + "name": "getStatusSummary", + "in": "query", + "required": false, + "schema": { + "type": "boolean" + } + } + ], + "security": [ + { + "basicAuth": [] + } + ] + }, + "post": { + "summary": "List agents by action ids", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/agent_get_by_actions" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agents-by-actions", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "actionIds": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "policy_id" + ] + } + } + } + } + } + }, + "/agents/bulk_upgrade": { + "post": { + "summary": "Bulk upgrade agents", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "actionId": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-upgrade-agents", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/bulk_upgrade_agents" + }, + "example": { + "version": "8.4.0", + "source_uri": "https://artifacts.elastic.co/downloads/beats/elastic-agent", + "rollout_duration_seconds": 3600, + "agents": [ + "agent1", + "agent2" + ], + "start_time": "2022-08-03T14:00:00.000Z" + } + } + } + } + } + }, + "/agents/action_status": { + "get": { + "summary": "Get agent action status", + "tags": [ + "Agent actions" + ], + "parameters": [ + { + "$ref": "#/components/parameters/page_size" + }, + { + "$ref": "#/components/parameters/page_index" + }, + { + "schema": { + "type": "integer", + "default": 5 + }, + "in": "query", + "name": "errorSize" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "actionId": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "COMPLETE", + "EXPIRED", + "CANCELLED", + "FAILED", + "IN_PROGRESS", + "ROLLOUT_PASSED" + ] + }, + "nbAgentsActioned": { + "type": "number", + "description": "number of agents actioned" + }, + "nbAgentsActionCreated": { + "type": "number", + "description": "number of agents included in action from kibana" + }, + "nbAgentsAck": { + "type": "number", + "description": "number of agents that acknowledged the action" + }, + "nbAgentsFailed": { + "type": "number", + "description": "number of agents that failed to execute the action" + }, + "version": { + "type": "string", + "description": "agent version number (UPGRADE action)" + }, + "startTime": { + "type": "string", + "description": "start time of action (scheduled actions)" + }, + "type": { + "type": "string", + "enum": [ + "POLICY_REASSIGN", + "UPGRADE", + "UNENROLL", + "FORCE_UNENROLL", + "UPDATE_TAGS", + "CANCEL", + "REQUEST_DIAGNOSTICS", + "SETTINGS", + "POLICY_CHANGE", + "INPUT_ACTION" + ] + }, + "expiration": { + "type": "string" + }, + "completionTime": { + "type": "string" + }, + "cancellationTime": { + "type": "string" + }, + "newPolicyId": { + "type": "string", + "description": "new policy id (POLICY_REASSIGN action)" + }, + "policyId": { + "type": "string", + "description": "policy id (POLICY_CHANGE action)" + }, + "revision": { + "type": "string", + "description": "new policy revision (POLICY_CHANGE action)" + }, + "creationTime": { + "type": "string", + "description": "creation time of action" + }, + "latestErrors": { + "type": "array", + "description": "latest errors that happened when the agents executed the action", + "items": { + "type": "object", + "properties": { + "agentId": { + "type": "string" + }, + "error": { + "type": "string" + }, + "timestamp": { + "type": "string" + } + } + } + } + }, + "required": [ + "actionId", + "complete", + "nbAgentsActioned", + "nbAgentsActionCreated", + "nbAgentsAck", + "nbAgentsFailed", + "status", + "creationTime", + "type" + ] + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "agents-action-status" + } + }, + "/agents/{agentId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "Get agent by ID", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/agent" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agent", + "parameters": [ + { + "$ref": "#/components/parameters/with_metrics" + } + ] + }, + "put": { + "summary": "Update agent by ID", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/agent" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "update-agent", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "user_provided_metadata": { + "type": "object" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "summary": "Delete agent by ID", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "action": { + "type": "string", + "enum": [ + "deleted" + ] + } + }, + "required": [ + "action" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "delete-agent", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/agents/{agentId}/actions": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Create agent action", + "tags": [ + "Agent actions" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "body": { + "type": "array", + "items": { + "type": "number" + } + }, + "statusCode": { + "type": "number" + }, + "headers": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "new-agent-action", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "action": { + "$ref": "#/components/schemas/agent_action" + } + } + } + } + } + } + } + }, + "/agents/{agentId}/actions/{actionId}/cancel": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "actionId", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Cancel agent action", + "tags": [ + "Agent actions" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/agent_action" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "agent-action-cancel", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/agents/files/{fileId}/{fileName}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "fileId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "fileName", + "in": "path", + "required": true + } + ], + "get": { + "summary": "Get file uploaded by agent", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "body": { + "type": "object", + "properties": { + "items": { + "type": "object", + "properties": { + "body": {}, + "headers": {} + } + } + } + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agent-upload-file" + } + }, + "/agents/files/{fileId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "fileId", + "in": "path", + "required": true + } + ], + "delete": { + "summary": "Delete file uploaded by agent", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "body": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "delete-agent-upload-file" + } + }, + "/agents/{agentId}/reassign": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Reassign agent", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "reassign-agent", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "policy_id": { + "type": "string" + } + }, + "required": [ + "policy_id" + ] + } + } + } + } + }, + "put": { + "summary": "Reassign agent", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "reassign-agent-deprecated", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "policy_id": { + "type": "string" + } + }, + "required": [ + "policy_id" + ] + } + } + } + }, + "deprecated": true + } + }, + "/agents/{agentId}/unenroll": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Unenroll agent", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "400": { + "description": "BAD REQUEST", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number", + "enum": [ + 400 + ] + } + } + } + } + } + } + }, + "operationId": "unenroll-agent", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "revoke": { + "type": "boolean" + }, + "force": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "/agents/{agentId}/upgrade": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Upgrade agent", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/upgrade_agent" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "upgrade-agent", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/upgrade_agent" + } + } + } + } + } + }, + "/agents/{agentId}/uploads": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "List agent uploads", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "body": { + "type": "object", + "properties": { + "item": { + "type": "array", + "items": { + "$ref": "#/components/schemas/agent_diagnostics" + } + } + } + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "list-agent-uploads" + } + }, + "/agents/bulk_reassign": { + "post": { + "summary": "Bulk reassign agents", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "actionId": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-reassign-agents", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "policy_id": { + "type": "string", + "description": "new agent policy id" + }, + "agents": { + "oneOf": [ + { + "type": "string", + "description": "KQL query string, leave empty to action all agents" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "description": "list of agent IDs" + } + ] + } + }, + "required": [ + "policy_id", + "agents" + ] + }, + "example": { + "policy_id": "policy_id", + "agents": "fleet-agents.policy_id : (\"policy1\" or \"policy2\")" + } + } + } + } + } + }, + "/agents/bulk_unenroll": { + "post": { + "summary": "Bulk unenroll agents", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "actionId": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-unenroll-agents", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "agents": { + "oneOf": [ + { + "type": "string", + "description": "KQL query string, leave empty to action all agents" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "description": "list of agent IDs" + } + ] + }, + "revoke": { + "type": "boolean", + "description": "Revokes API keys of agents" + }, + "force": { + "type": "boolean", + "description": "Unenrolls hosted agents too" + }, + "includeInactive": { + "type": "boolean", + "description": "When passing agents by KQL query, unenrolls inactive agents too" + } + }, + "required": [ + "agents" + ] + }, + "example": { + "revoke": true, + "force": false, + "agents": [ + "agent1", + "agent2" + ] + } + } + } + } + } + }, + "/agents/bulk_update_agent_tags": { + "post": { + "summary": "Bulk update agent tags", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "actionId": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-update-agent-tags", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "agents": { + "oneOf": [ + { + "type": "string", + "description": "KQL query string, leave empty to action all agents" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "description": "list of agent IDs" + } + ] + }, + "tagsToAdd": { + "type": "array", + "items": { + "type": "string" + } + }, + "tagsToRemove": { + "type": "array", + "items": { + "type": "string" + } + }, + "batchSize": { + "type": "number" + } + }, + "required": [ + "agents" + ] + }, + "example": { + "agents": [ + "agent1", + "agent2" + ], + "tagsToAdd": [ + "newTag" + ], + "tagsToRemove": [ + "existingTag" + ] + } + } + } + } + } + }, + "/agents/tags": { + "get": { + "summary": "List agent tags", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_agent_tags_response" + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-agent-tags" + } + }, + "/agents/{agentId}/request_diagnostics": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentId", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Request agent diagnostics", + "tags": [ + "Agents" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "additional_metrics": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string", + "enum": [ + "CPU" + ] + } + ] + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "actionId": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "request-diagnostics-agent", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/agents/bulk_request_diagnostics": { + "post": { + "summary": "Bulk request diagnostics from agents", + "tags": [ + "Agents" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "actionId": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-request-diagnostics", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "batchSize": { + "type": "number" + }, + "agents": { + "oneOf": [ + { + "type": "string", + "description": "KQL query string, leave empty to action all agents" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "description": "list of agent IDs" + } + ] + }, + "additional_metrics": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string", + "enum": [ + "CPU" + ] + } + ] + } + } + }, + "required": [ + "agents" + ] + }, + "example": { + "agents": "fleet-agents.policy_id : (\"policy1\" or \"policy2\")" + } + } + } + } + } + }, + "/agent_policies": { + "get": { + "summary": "List agent policies", + "tags": [ + "Agent policies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/agent_policy" + } + }, + "total": { + "type": "number" + }, + "page": { + "type": "number" + }, + "perPage": { + "type": "number" + } + }, + "required": [ + "items", + "total", + "page", + "perPage" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "agent-policy-list", + "parameters": [ + { + "$ref": "#/components/parameters/page_size" + }, + { + "$ref": "#/components/parameters/page_index" + }, + { + "$ref": "#/components/parameters/kuery" + }, + { + "schema": { + "type": "boolean" + }, + "in": "query", + "name": "full", + "description": "When set to true, retrieve the related package policies for each agent policy." + }, + { + "schema": { + "type": "boolean" + }, + "in": "query", + "name": "noAgentCount", + "description": "When set to true, do not count how many agents are in the agent policy, this can improve performance if you are searching over a large number of agent policies. The \"agents\" property will always be 0 if set to true." + } + ], + "description": "" + }, + "post": { + "summary": "Create agent policy", + "tags": [ + "Agent policies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/agent_policy" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "create-agent-policy", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/agent_policy_create_request" + } + } + } + }, + "security": [], + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/agent_policies/{agentPolicyId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentPolicyId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "Get agent policy by ID", + "tags": [ + "Agent policies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/agent_policy" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "agent-policy-info", + "description": "Get one agent policy", + "parameters": [] + }, + "put": { + "summary": "Update agent policy by ID", + "tags": [ + "Agent policies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/agent_policy" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "update-agent-policy", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/agent_policy_update_request" + } + } + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/agent_policies/{agentPolicyId}/copy": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentPolicyId", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Copy agent policy by ID", + "tags": [ + "Agent policies" + ], + "operationId": "agent-policy-copy", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/agent_policy" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + } + }, + "description": "" + } + } + }, + "/agent_policies/{agentPolicyId}/full": { + "get": { + "summary": "Get full agent policy by ID", + "tags": [ + "Agent policies" + ], + "operationId": "agent-policy-full", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/components/schemas/agent_policy_full" + } + ] + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + } + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentPolicyId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "download", + "in": "query", + "required": false + }, + { + "schema": { + "type": "string" + }, + "name": "standalone", + "in": "query", + "required": false + }, + { + "schema": { + "type": "string" + }, + "name": "kubernetes", + "in": "query", + "required": false + } + ] + }, + "/agent_policies/{agentPolicyId}/download": { + "get": { + "summary": "Download agent policy by ID", + "tags": [ + "Agent policies" + ], + "operationId": "agent-policy-download", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + } + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "agentPolicyId", + "in": "path", + "required": true + }, + { + "schema": { + "type": "string" + }, + "name": "download", + "in": "query", + "required": false + }, + { + "schema": { + "type": "string" + }, + "name": "standalone", + "in": "query", + "required": false + }, + { + "schema": { + "type": "string" + }, + "name": "kubernetes", + "in": "query", + "required": false + } + ] + }, + "/agent_policies/_bulk_get": { + "post": { + "summary": "Bulk get agent policies", + "tags": [ + "Agent policies" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "string" + }, + "description": "list of agent policy ids" + }, + "full": { + "type": "boolean", + "description": "get full policies with package policies populated" + }, + "ignoreMissing": { + "type": "boolean" + } + }, + "required": [ + "ids" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/agent_policy" + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-get-agent-policies", + "security": [], + "parameters": [] + } + }, + "/agent_policies/delete": { + "post": { + "summary": "Delete agent policy by ID", + "tags": [ + "Agent policies" + ], + "operationId": "delete-agent-policy", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "id", + "success" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "agentPolicyId": { + "type": "string" + }, + "force": { + "type": "boolean", + "description": "bypass validation checks that can prevent agent policy deletion" + } + }, + "required": [ + "agentPolicyId" + ] + } + } + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + }, + "parameters": [] + }, + "/data_streams": { + "get": { + "summary": "List data streams", + "tags": [ + "Data streams" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data_streams": { + "type": "array", + "items": { + "$ref": "#/components/schemas/data_stream" + } + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "data-streams-list" + }, + "parameters": [] + }, + "/enrollment-api-keys": { + "get": { + "summary": "List enrollment API keys", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/components/schemas/enrollment_api_key" + }, + "deprecated": true + }, + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/enrollment_api_key" + } + }, + "page": { + "type": "number" + }, + "perPage": { + "type": "number" + }, + "total": { + "type": "number" + } + }, + "required": [ + "items", + "page", + "perPage", + "total" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-enrollment-api-keys-deprecated", + "parameters": [], + "deprecated": true + }, + "post": { + "summary": "Create enrollment API key", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/enrollment_api_key" + }, + "action": { + "type": "string", + "enum": [ + "created" + ] + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "create-enrollment-api-keys-deprecated", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "deprecated": true + } + }, + "/enrollment-api-keys/{keyId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "keyId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "Get enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/enrollment_api_key" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-enrollment-api-key-deprecated", + "deprecated": true + }, + "delete": { + "summary": "Delete enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "action": { + "type": "string", + "enum": [ + "deleted" + ] + } + }, + "required": [ + "action" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "delete-enrollment-api-key-deprecated", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ], + "deprecated": true + } + }, + "/enrollment_api_keys": { + "get": { + "summary": "List enrollment API keys", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/components/schemas/enrollment_api_key" + }, + "deprecated": true + }, + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/enrollment_api_key" + } + }, + "page": { + "type": "number" + }, + "perPage": { + "type": "number" + }, + "total": { + "type": "number" + } + }, + "required": [ + "items", + "page", + "perPage", + "total" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-enrollment-api-keys", + "parameters": [] + }, + "post": { + "summary": "Create enrollment API key", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/enrollment_api_key" + }, + "action": { + "type": "string", + "enum": [ + "created" + ] + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "create-enrollment-api-keys", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/enrollment_api_keys/{keyId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "keyId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "Get enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/enrollment_api_key" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-enrollment-api-key" + }, + "delete": { + "summary": "Delete enrollment API key by ID", + "tags": [ + "Enrollment API keys" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "action": { + "type": "string", + "enum": [ + "deleted" + ] + } + }, + "required": [ + "action" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "delete-enrollment-api-key", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/package_policies": { + "get": { + "summary": "List package policies", + "tags": [ + "Package policies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/package_policy" + } + }, + "total": { + "type": "number" + }, + "page": { + "type": "number" + }, + "perPage": { + "type": "number" + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-package-policies", + "security": [], + "parameters": [ + { + "$ref": "#/components/parameters/page_size" + }, + { + "$ref": "#/components/parameters/page_index" + }, + { + "$ref": "#/components/parameters/kuery" + }, + { + "$ref": "#/components/parameters/format" + } + ] + }, + "parameters": [], + "post": { + "summary": "Create package policy", + "tags": [ + "Package policies" + ], + "operationId": "create-package-policy", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/package_policy" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + }, + "409": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "description": "You should use inputs as an object and not use the deprecated inputs array.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/package_policy_request" + } + } + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "$ref": "#/components/parameters/format" + } + ] + } + }, + "/package_policies/_bulk_get": { + "post": { + "summary": "Bulk get package policies", + "tags": [ + "Package policies" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "string" + }, + "description": "list of package policy ids" + }, + "ignoreMissing": { + "type": "boolean" + } + }, + "required": [ + "ids" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/package_policy" + } + } + }, + "required": [ + "items" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "bulk-get-package-policies", + "security": [], + "parameters": [ + { + "$ref": "#/components/parameters/format" + } + ] + } + }, + "/package_policies/delete": { + "post": { + "summary": "Delete package policy", + "tags": [ + "Package policies" + ], + "operationId": "post-delete-package-policy", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "packagePolicyIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "force": { + "type": "boolean" + } + }, + "required": [ + "packagePolicyIds" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "id", + "success" + ] + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/package_policies/upgrade": { + "post": { + "summary": "Upgrade package policy to a newer package version", + "tags": [ + "Package policies" + ], + "operationId": "upgrade-package-policy", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "packagePolicyIds": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "packagePolicyIds" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "id", + "success" + ] + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + }, + "409": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/package_policies/upgrade/dryrun": { + "post": { + "summary": "Dry run package policy upgrade", + "tags": [ + "Package policies" + ], + "operationId": "upgrade-package-policy-dry-run", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "packagePolicyIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "packageVersion": { + "type": "string" + } + }, + "required": [ + "packagePolicyIds" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "hasErrors": { + "type": "boolean" + }, + "diff": { + "$ref": "#/components/schemas/upgrade_diff" + }, + "agent_diff": { + "$ref": "#/components/schemas/upgrade_agent_diff" + } + }, + "required": [ + "hasErrors" + ] + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + } + } + }, + "/package_policies/{packagePolicyId}": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "packagePolicyId", + "in": "path", + "required": true + } + ], + "get": { + "summary": "Get package policy by ID", + "tags": [ + "Package policies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/package_policy" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-package-policy", + "parameters": [ + { + "$ref": "#/components/parameters/format" + } + ] + }, + "put": { + "summary": "Update package policy by ID", + "tags": [ + "Package policies" + ], + "operationId": "update-package-policy", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/package_policy_request" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/package_policy" + }, + "sucess": { + "type": "boolean" + } + }, + "required": [ + "item", + "sucess" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + }, + { + "$ref": "#/components/parameters/format" + } + ] + }, + "delete": { + "summary": "Delete package policy by ID", + "tags": [ + "Package policies" + ], + "operationId": "delete-package-policy", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "schema": { + "type": "boolean" + }, + "name": "force", + "in": "query" + } + ] + } + }, + "/outputs": { + "get": { + "summary": "List outputs", + "tags": [ + "Outputs" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/output_create_request" + } + }, + "total": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "perPage": { + "type": "integer" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-outputs" + }, + "post": { + "summary": "Create output", + "tags": [ + "Outputs" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/output_create_request" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/output_create_request" + } + } + } + }, + "operationId": "post-outputs" + } + }, + "/outputs/{outputId}": { + "get": { + "summary": "Get output by ID", + "tags": [ + "Outputs" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/output_create_request" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-output" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "outputId", + "in": "path", + "required": true + } + ], + "delete": { + "summary": "Delete output by ID", + "tags": [ + "Outputs" + ], + "operationId": "delete-output", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + }, + "put": { + "summary": "Update output by ID", + "tags": [ + "Outputs" + ], + "operationId": "update-output", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/output_update_request" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/output_update_request" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/outputs/{outputId}/health": { + "get": { + "summary": "Get latest output health", + "tags": [ + "Outputs" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "state": { + "type": "string", + "description": "state of output, HEALTHY or DEGRADED" + }, + "message": { + "type": "string", + "description": "long message if unhealthy" + }, + "timestamp": { + "type": "string", + "description": "timestamp of reported state" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-output-health" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "outputId", + "in": "path", + "required": true + } + ] + }, + "/logstash_api_keys": { + "post": { + "summary": "Generate Logstash API key", + "tags": [ + "Outputs" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "api_key": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "generate-logstash-api-key", + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/agent_download_sources": { + "get": { + "summary": "List agent binary download sources", + "tags": [ + "Agent binary download sources" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/download_sources" + } + }, + "total": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "perPage": { + "type": "integer" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-download-sources" + }, + "post": { + "summary": "Create agent binary download source", + "tags": [ + "Agent binary download sources" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/download_sources" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "host": { + "type": "string" + } + }, + "required": [ + "name", + "host", + "is_default" + ] + } + } + } + }, + "operationId": "post-download-sources" + } + }, + "/agent_download_sources/{sourceId}": { + "get": { + "summary": "Get agent binary download source by ID", + "tags": [ + "Agent binary download sources" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/download_sources" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-one-download-source" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "sourceId", + "in": "path", + "required": true + } + ], + "delete": { + "summary": "Delete agent binary download source by ID", + "tags": [ + "Agent binary download sources" + ], + "operationId": "delete-download-source", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + }, + "put": { + "summary": "Update agent binary download source by ID", + "tags": [ + "Agent binary download sources" + ], + "operationId": "update-download-source", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "host": { + "type": "string" + } + }, + "required": [ + "name", + "is_default", + "host" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/download_sources" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/fleet_server_hosts": { + "get": { + "summary": "List Fleet Server hosts", + "tags": [ + "Fleet Server hosts" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/fleet_server_host" + } + }, + "total": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "perPage": { + "type": "integer" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-fleet-server-hosts" + }, + "post": { + "summary": "Create Fleet Server host", + "tags": [ + "Fleet Server hosts" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/fleet_server_host" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "proxy_id": { + "description": "The ID of the proxy to use for this fleet server host. See the proxies API for more information.", + "type": "string" + }, + "host_urls": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "name", + "host_urls" + ] + } + } + } + }, + "operationId": "post-fleet-server-hosts" + } + }, + "/fleet_server_hosts/{itemId}": { + "get": { + "summary": "Get Fleet Server host by ID", + "tags": [ + "Fleet Server hosts" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/fleet_server_host" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-one-fleet-server-hosts" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "itemId", + "in": "path", + "required": true + } + ], + "delete": { + "summary": "Delete Fleet Server host by ID", + "tags": [ + "Fleet Server hosts" + ], + "operationId": "delete-fleet-server-hosts", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + }, + "put": { + "summary": "Update Fleet Server host by ID", + "tags": [ + "Fleet Server hosts" + ], + "operationId": "update-fleet-server-hosts", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "proxy_id": { + "description": "The ID of the proxy to use for this fleet server host. See the proxies API for more information.", + "type": "string", + "nullable": true + }, + "host_urls": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/fleet_server_host" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/proxies": { + "get": { + "summary": "List proxies", + "tags": [ + "Proxies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/proxies" + } + }, + "total": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "perPage": { + "type": "integer" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-fleet-proxies" + }, + "post": { + "summary": "Create proxy", + "tags": [ + "Proxies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/proxies" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_headers": { + "type": "object" + }, + "certificate_authorities": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "certificate_key": { + "type": "string" + } + }, + "required": [ + "name", + "url" + ] + } + } + } + }, + "operationId": "post-fleet-proxies" + } + }, + "/proxies/{itemId}": { + "get": { + "summary": "Get proxy by ID", + "tags": [ + "Proxies" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/proxies" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-one-fleet-proxies" + }, + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "itemId", + "in": "path", + "required": true + } + ], + "delete": { + "summary": "Delete proxy by ID", + "tags": [ + "Proxies" + ], + "operationId": "delete-fleet-proxies", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + }, + "put": { + "summary": "Update proxy by ID", + "tags": [ + "Proxies" + ], + "operationId": "update-fleet-proxies", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_headers": { + "type": "object" + }, + "certificate_authorities": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "certificate_key": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/proxies" + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/kbn_xsrf" + } + ] + } + }, + "/kubernetes": { + "get": { + "summary": "Get full K8s agent manifest", + "tags": [ + "Kubernetes" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "type": "string" + } + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-full-k8s-manifest", + "parameters": [ + { + "schema": { + "type": "boolean" + }, + "name": "download", + "in": "query", + "required": false + }, + { + "schema": { + "type": "string" + }, + "name": "fleetServer", + "in": "query", + "required": false + }, + { + "schema": { + "type": "string" + }, + "name": "enrolToken", + "in": "query", + "required": false + } + ] + } + }, + "/uninstall_tokens": { + "get": { + "summary": "List metadata for latest uninstall tokens per agent policy", + "tags": [ + "Uninstall tokens" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "policy_id": { + "type": "string" + }, + "created_at": { + "type": "string" + } + }, + "required": [ + "id", + "policy_id", + "created_at" + ] + } + }, + "total": { + "type": "number" + }, + "page": { + "type": "number" + }, + "perPage": { + "type": "number" + } + }, + "required": [ + "items", + "total", + "page", + "perPage" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-uninstall-tokens", + "parameters": [ + { + "name": "perPage", + "in": "query", + "description": "The number of items to return", + "required": false, + "schema": { + "type": "integer", + "default": 20, + "minimum": 5 + } + }, + { + "$ref": "#/components/parameters/page_index" + }, + { + "name": "policyId", + "in": "query", + "description": "Partial match filtering for policy IDs", + "required": false, + "schema": { + "type": "string" + } + } + ] + } + }, + "/uninstall_tokens/{uninstallTokenId}": { + "get": { + "summary": "Get one decrypted uninstall token by its ID", + "tags": [ + "Uninstall tokens" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "token": { + "type": "string" + }, + "policy_id": { + "type": "string" + }, + "created_at": { + "type": "string" + } + }, + "required": [ + "id", + "token", + "policy_id", + "created_at" + ] + } + }, + "required": [ + "item" + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/error" + } + }, + "operationId": "get-uninstall-token", + "parameters": [ + { + "name": "uninstallTokenId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ] + } + } + }, + "components": { + "securitySchemes": { + "basicAuth": { + "type": "http", + "scheme": "basic" + }, + "Enrollment_API_Key": { + "name": "Authorization", + "type": "apiKey", + "in": "header", + "description": "e.g. Authorization: ApiKey base64EnrollmentApiKey" + }, + "Access_API_Key": { + "name": "Authorization", + "type": "apiKey", + "in": "header", + "description": "e.g. Authorization: ApiKey base64AccessApiKey" + } + }, + "parameters": { + "kbn_xsrf": { + "schema": { + "type": "string" + }, + "in": "header", + "name": "kbn-xsrf", + "required": true, + "description": "Kibana's anti Cross-Site Request Forgery token. Can be any string value." + }, + "page_size": { + "name": "perPage", + "in": "query", + "description": "The number of items to return", + "required": false, + "schema": { + "type": "integer", + "default": 20 + } + }, + "page_index": { + "name": "page", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "default": 1 + } + }, + "kuery": { + "name": "kuery", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + }, + "show_inactive": { + "name": "showInactive", + "in": "query", + "required": false, + "schema": { + "type": "boolean" + } + }, + "show_upgradeable": { + "name": "showUpgradeable", + "in": "query", + "required": false, + "schema": { + "type": "boolean" + } + }, + "sort_field": { + "name": "sortField", + "in": "query", + "required": false, + "schema": { + "type": "string", + "deprecated": true + } + }, + "sort_order": { + "name": "sortOrder", + "in": "query", + "required": false, + "schema": { + "type": "string", + "enum": [ + "asc", + "desc" + ] + } + }, + "with_metrics": { + "name": "withMetrics", + "in": "query", + "description": "Return agent metrics, false by default", + "required": false, + "schema": { + "type": "boolean" + } + }, + "format": { + "name": "format", + "in": "query", + "description": "Simplified or legacy format for package inputs", + "required": false, + "schema": { + "type": "string", + "enum": [ + "simplified", + "legacy" + ] + } + } + }, + "responses": { + "error": { + "description": "Generic Error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "statusCode": { + "type": "number" + }, + "error": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + } + } + } + }, + "schemas": { + "fleet_setup_response": { + "title": "Fleet Setup response", + "type": "object", + "properties": { + "isInitialized": { + "type": "boolean" + }, + "nonFatalErrors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "message": { + "type": "string" + } + }, + "required": [ + "name", + "message" + ] + } + } + }, + "required": [ + "isInitialized", + "nonFatalErrors" + ] + }, + "settings": { + "title": "Settings", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "has_seen_add_data_notice": { + "type": "boolean" + }, + "fleet_server_hosts": { + "deprecated": true, + "type": "array", + "items": { + "type": "string" + } + }, + "prerelease_integrations_enabled": { + "type": "boolean" + } + }, + "required": [ + "fleet_server_hosts", + "id" + ] + }, + "fleet_settings_response": { + "title": "Fleet settings response", + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/settings" + } + }, + "required": [ + "item" + ] + }, + "fleet_server_host": { + "title": "Fleet Server Host", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "is_preconfigured": { + "type": "boolean" + }, + "proxy_id": { + "type": "string" + }, + "host_urls": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "fleet_server_hosts", + "id", + "is_default", + "is_preconfigured", + "host_urls" + ] + }, + "proxies": { + "title": "Fleet Proxy", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_headers": { + "type": "object" + }, + "certificate_authorities": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "certificate_key": { + "type": "string" + } + }, + "required": [ + "name", + "url" + ] + }, + "download_sources": { + "title": "Download Source", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "host": { + "type": "string" + }, + "proxy_id": { + "description": "The ID of the proxy to use for this download source. See the proxies API for more information.", + "type": "string", + "nullable": true + } + }, + "required": [ + "is_default", + "name", + "host" + ] + }, + "fleet_settings_enrollment_response": { + "title": "Fleet settings response", + "type": "object", + "properties": { + "fleet_server": { + "type": "object", + "properties": { + "policies": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "is_managed": { + "type": "boolean" + }, + "is_default_fleet_server": { + "type": "boolean" + }, + "has_fleet_server": { + "type": "boolean" + }, + "fleet_server_host_id": { + "type": "string" + }, + "download_source_id": { + "type": "string" + } + }, + "required": [ + "id", + "name", + "is_managed" + ] + } + }, + "has_active": { + "type": "boolean" + }, + "host": { + "$ref": "#/components/schemas/fleet_server_host" + }, + "host_proxy": { + "$ref": "#/components/schemas/proxies" + } + }, + "required": [ + "agent_policies", + "has_active" + ] + }, + "download_source": { + "$ref": "#/components/schemas/download_sources" + } + }, + "required": [ + "fleet_server" + ] + }, + "saved_object_type": { + "title": "Saved Object type", + "oneOf": [ + { + "type": "string", + "enum": [ + "dashboard", + "visualization", + "search", + "index_pattern", + "map", + "lens", + "security_rule", + "csp_rule_template", + "ml_module", + "tag", + "osquery_pack_asset", + "osquery_saved_query" + ] + }, + { + "type": "string", + "enum": [ + "index", + "component_template", + "ingest_pipeline", + "index_template", + "ilm_policy", + "transform", + "data_stream_ilm_policy", + "ml_model" + ] + } + ] + }, + "get_bulk_assets_response": { + "title": "Bulk get assets response", + "type": "object", + "deprecated": true, + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/saved_object_type" + }, + "updatedAt": { + "type": "string" + }, + "attributes": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, + "appLink": { + "type": "string" + } + } + } + } + }, + "required": [ + "items" + ] + }, + "get_categories_response": { + "title": "Get categories response", + "type": "object", + "properties": { + "response": { + "type": "array", + "items": { + "type": "object", + "deprecated": true, + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "count": { + "type": "number" + } + }, + "required": [ + "id", + "title", + "count" + ] + } + }, + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "count": { + "type": "number" + } + }, + "required": [ + "id", + "title", + "count" + ] + } + } + }, + "required": [ + "items" + ] + }, + "kibana_saved_object_type": { + "title": "Kibana saved object asset type", + "type": "string", + "enum": [ + "dashboard", + "visualization", + "search", + "index-pattern", + "map", + "lens", + "ml-module", + "security-rule", + "csp_rule_template" + ] + }, + "elasticsearch_asset_type": { + "title": "Elasticsearch asset type", + "type": "string", + "enum": [ + "component_template", + "ingest_pipeline", + "index_template", + "ilm_policy", + "transform", + "data_stream_ilm_policy" + ] + }, + "installation_info": { + "title": "Installation info object", + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "namespaces": { + "type": "array", + "items": { + "type": "string" + } + }, + "installed_kibana": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/kibana_saved_object_type" + } + } + }, + "installed_es": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "deferred": { + "type": "boolean" + }, + "type": { + "$ref": "#/components/schemas/elasticsearch_asset_type" + } + } + }, + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "install_status": { + "type": "string", + "enum": [ + "installed", + "installing", + "install_failed" + ] + }, + "install_source": { + "type": "string", + "enum": [ + "registry", + "upload", + "bundled" + ] + }, + "install_kibana_space_id": { + "type": "string" + }, + "install_format_schema_version": { + "type": "string" + }, + "latest_install_failed_attempts": { + "description": "Latest failed install errors", + "type": "array", + "items": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "target_version": { + "type": "string" + }, + "error": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "message": { + "type": "string" + }, + "stack": { + "type": "string" + } + } + } + } + } + }, + "latest_executed_state": { + "description": "Latest successfully executed state in package install state machine", + "type": "object", + "properties": { + "name": { + "type": "string", + "enum": [ + "create_restart_installation", + "install_kibana_assets", + "install_ilm_policies", + "install_ml_model", + "install_index_template_pipelines", + "remove_legacy_templates", + "update_current_write_indices", + "install_transforms", + "delete_previous_pipelines", + "save_archive_entries_from_assets_map", + "update_so" + ] + }, + "started_at": { + "type": "string" + }, + "error": { + "type": "string" + } + } + }, + "verification_status": { + "type": "string", + "enum": [ + "verified", + "unverified", + "unknown" + ] + }, + "verification_key_id": { + "type": "string", + "nullable": true + }, + "experimental_data_stream_features": { + "type": "array", + "properties": { + "data_stream": { + "type": "string" + }, + "features": { + "type": "object", + "properties": { + "synthetic_source": { + "type": "boolean", + "nullable": true + }, + "tsdb": { + "type": "boolean", + "nullable": true + }, + "doc_value_only_numeric": { + "type": "boolean", + "nullable": true + }, + "doc_value_only_other": { + "type": "boolean", + "nullable": true + } + } + } + } + } + }, + "required": [ + "installed_kibana", + "installed_es", + "name", + "version", + "install_status", + "install_version", + "install_started_at", + "install_source", + "verification_status", + "latest_install_failed_attempts" + ] + }, + "search_result": { + "title": "Search result", + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "download": { + "type": "string" + }, + "icons": { + "type": "string" + }, + "name": { + "type": "string" + }, + "path": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "version": { + "type": "string" + }, + "status": { + "type": "string" + }, + "installationInfo": { + "$ref": "#/components/schemas/installation_info" + }, + "savedObject": { + "type": "object", + "deprecated": true + } + }, + "required": [ + "description", + "download", + "icons", + "name", + "path", + "title", + "type", + "version", + "status" + ] + }, + "get_packages_response": { + "title": "Get Packages response", + "type": "object", + "properties": { + "response": { + "type": "array", + "deprecated": true, + "items": { + "$ref": "#/components/schemas/search_result" + } + }, + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/search_result" + } + } + }, + "required": [ + "items" + ] + }, + "bulk_install_packages_response": { + "title": "Bulk install packages response", + "type": "object", + "properties": { + "response": { + "type": "array", + "deprecated": true, + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + }, + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + } + }, + "required": [ + "items" + ] + }, + "package_info": { + "title": "Package information", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "title": { + "type": "string" + }, + "version": { + "type": "string" + }, + "release": { + "type": "string", + "deprecated": true, + "description": "release label is deprecated, derive from the version instead (packages follow semver)", + "enum": [ + "experimental", + "beta", + "ga" + ] + }, + "source": { + "type": "object", + "properties": { + "license": { + "type": "string", + "enum": [ + "Apache-2.0", + "Elastic-2.0" + ] + } + } + }, + "readme": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string" + }, + "categories": { + "type": "array", + "items": { + "type": "string" + } + }, + "conditions": { + "type": "object", + "properties": { + "kibana": { + "type": "object", + "properties": { + "versions": { + "type": "string" + } + } + }, + "elasticsearch": { + "type": "object", + "properties": { + "subscription": { + "type": "string", + "enum": [ + "basic", + "gold", + "platinum", + "enterprise" + ] + } + } + } + } + }, + "screenshots": { + "type": "array", + "items": { + "type": "object", + "properties": { + "src": { + "type": "string" + }, + "path": { + "type": "string" + }, + "title": { + "type": "string" + }, + "size": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "src", + "path" + ] + } + }, + "icons": { + "type": "array", + "items": { + "type": "string" + } + }, + "assets": { + "type": "array", + "items": { + "type": "string" + } + }, + "internal": { + "type": "boolean" + }, + "format_version": { + "type": "string" + }, + "data_streams": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "name": { + "type": "string" + }, + "release": { + "type": "string" + }, + "ingeset_pipeline": { + "type": "string" + }, + "vars": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "default": { + "type": "string" + } + }, + "required": [ + "name", + "default" + ] + } + }, + "type": { + "type": "string" + }, + "package": { + "type": "string" + } + }, + "required": [ + "title", + "name", + "release", + "ingeset_pipeline", + "type", + "package" + ] + } + }, + "download": { + "type": "string" + }, + "path": { + "type": "string" + }, + "elasticsearch": { + "type": "object", + "properties": { + "privileges": { + "type": "object", + "properties": { + "cluster": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + }, + "required": [ + "name", + "title", + "version", + "description", + "type", + "categories", + "conditions", + "assets", + "format_version", + "download", + "path" + ] + }, + "package_usage_stats": { + "title": "Package usage stats", + "type": "object", + "properties": { + "agent_policy_count": { + "type": "integer" + } + }, + "required": [ + "agent_policy_count" + ] + }, + "fleet_status_response": { + "title": "Fleet status response", + "type": "object", + "properties": { + "isReady": { + "type": "boolean" + }, + "missing_requirements": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "tls_required", + "api_keys", + "fleet_admin_user", + "fleet_server" + ] + } + }, + "missing_optional_features": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "encrypted_saved_object_encryption_key_required" + ] + } + }, + "package_verification_key_id": { + "type": "string" + } + }, + "required": [ + "isReady", + "missing_requirements", + "missing_optional_features" + ] + }, + "agent_type": { + "type": "string", + "title": "Agent type", + "enum": [ + "PERMANENT", + "EPHEMERAL", + "TEMPORARY" + ] + }, + "agent_metadata": { + "title": "Agent metadata", + "type": "object" + }, + "agent_status": { + "type": "string", + "title": "Agent status", + "enum": [ + "offline", + "error", + "online", + "inactive", + "warning" + ] + }, + "agent_component_status": { + "title": "Agent component status", + "type": "string", + "enum": [ + "starting", + "configuring", + "healthy", + "degraded", + "failed", + "stopping", + "stopped" + ] + }, + "agent_component_unit_type": { + "title": "Agent component unit type", + "type": "string", + "enum": [ + "input", + "output" + ] + }, + "agent_component_unit": { + "title": "Agent component unit", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/agent_component_unit_type" + }, + "status": { + "$ref": "#/components/schemas/agent_component_status" + }, + "message": { + "type": "string" + }, + "payload": { + "type": "object" + } + } + }, + "agent_component": { + "title": "Agent component", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/agent_component_status" + }, + "message": { + "type": "string" + }, + "units": { + "type": "array", + "items": { + "$ref": "#/components/schemas/agent_component_unit" + } + } + } + }, + "agent": { + "title": "Agent", + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/agent_type" + }, + "active": { + "type": "boolean" + }, + "enrolled_at": { + "type": "string" + }, + "unenrolled_at": { + "type": "string" + }, + "unenrollment_started_at": { + "type": "string" + }, + "access_api_key_id": { + "type": "string" + }, + "default_api_key_id": { + "type": "string" + }, + "policy_id": { + "type": "string" + }, + "policy_revision": { + "type": "number" + }, + "last_checkin": { + "type": "string" + }, + "user_provided_metadata": { + "$ref": "#/components/schemas/agent_metadata" + }, + "local_metadata": { + "$ref": "#/components/schemas/agent_metadata" + }, + "id": { + "type": "string" + }, + "access_api_key": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/agent_status" + }, + "default_api_key": { + "type": "string" + }, + "components": { + "type": "array", + "items": { + "$ref": "#/components/schemas/agent_component" + } + }, + "metrics": { + "type": "object", + "properties": { + "cpu_avg": { + "type": "number", + "description": "Average agent CPU usage during the last 5 minutes, number between 0-1" + }, + "memory_size_byte_avg": { + "type": "number", + "description": "Average agent memory consumption during the last 5 minutes" + } + } + } + }, + "required": [ + "type", + "active", + "enrolled_at", + "id", + "status" + ] + }, + "get_agents_response": { + "title": "Get Agent response", + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/components/schemas/agent" + }, + "deprecated": true + }, + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/agent" + } + }, + "total": { + "type": "number" + }, + "page": { + "type": "number" + }, + "perPage": { + "type": "number" + }, + "statusSummary": { + "type": "object", + "properties": { + "offline": { + "type": "number" + }, + "error": { + "type": "number" + }, + "online": { + "type": "number" + }, + "inactive": { + "type": "number" + }, + "enrolling": { + "type": "number" + }, + "unenrolling": { + "type": "number" + }, + "unenrolled": { + "type": "number" + }, + "updating": { + "type": "number" + }, + "degraded'": { + "type": "number" + } + } + } + }, + "required": [ + "items", + "total", + "page", + "perPage" + ] + }, + "agent_get_by_actions": { + "title": "Agents get by action ids", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "bulk_upgrade_agents": { + "title": "Bulk upgrade agents", + "type": "object", + "properties": { + "version": { + "type": "string", + "description": "version to upgrade to" + }, + "source_uri": { + "type": "string", + "description": "alternative upgrade binary download url" + }, + "rollout_duration_seconds": { + "type": "number", + "description": "rolling upgrade window duration in seconds" + }, + "start_time": { + "type": "string", + "description": "start time of upgrade in ISO 8601 format" + }, + "agents": { + "oneOf": [ + { + "type": "string", + "description": "KQL query string, leave empty to action all agents" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "description": "list of agent IDs" + } + ] + }, + "force": { + "type": "boolean", + "description": "Force upgrade, skipping validation (should be used with caution)" + }, + "skipRateLimitCheck": { + "type": "boolean", + "description": "Skip rate limit check for upgrade" + } + }, + "required": [ + "agents", + "version" + ] + }, + "agent_action": { + "title": "Agent action", + "oneOf": [ + { + "properties": { + "data": { + "type": "string" + }, + "ack_data": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "UNENROLL", + "UPGRADE", + "POLICY_REASSIGN" + ] + } + } + }, + { + "properties": { + "type": { + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "log_level": { + "type": "string", + "nullable": true, + "enum": [ + "debug", + "info", + "warning", + "error" + ] + } + } + } + } + } + ] + }, + "upgrade_agent": { + "title": "Upgrade agent", + "type": "object", + "properties": { + "version": { + "type": "string" + }, + "source_uri": { + "type": "string" + }, + "force": { + "type": "boolean", + "description": "Force upgrade, skipping validation (should be used with caution)" + }, + "skipRateLimitCheck": { + "type": "boolean", + "description": "Skip rate limit check for upgrade" + } + }, + "required": [ + "version" + ] + }, + "agent_diagnostics": { + "title": "Agent diagnostics", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "createTime": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "actionId": { + "type": "string" + }, + "status": { + "enum": [ + "READY", + "AWAITING_UPLOAD", + "DELETED", + "IN_PROGRESS" + ] + } + }, + "required": [ + "id", + "name", + "createTime", + "filePath", + "actionId", + "status" + ] + }, + "get_agent_tags_response": { + "title": "Get Agent Tags response", + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "new_package_policy": { + "title": "New package policy", + "type": "object", + "description": "", + "properties": { + "enabled": { + "type": "boolean" + }, + "package": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "title": { + "type": "string" + }, + "requires_root": { + "type": "boolean" + } + }, + "required": [ + "name", + "version" + ] + }, + "namespace": { + "type": "string" + }, + "output_id": { + "type": "string", + "deprecated": true + }, + "inputs": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "processors": { + "type": "array", + "items": { + "type": "string" + } + }, + "streams": { + "type": "array", + "items": {} + }, + "config": { + "type": "object" + }, + "vars": { + "type": "object" + } + }, + "required": [ + "type", + "enabled" + ] + } + }, + "policy_id": { + "type": "string", + "deprecated": true + }, + "policy_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "overrides": { + "type": "object" + } + }, + "required": [ + "inputs", + "name" + ] + }, + "package_policy": { + "title": "Package policy", + "allOf": [ + { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "revision": { + "type": "number" + }, + "inputs": { + "oneOf": [ + { + "type": "array", + "items": {} + }, + { + "type": "object" + } + ] + } + }, + "required": [ + "id", + "revision" + ] + }, + { + "$ref": "#/components/schemas/new_package_policy" + } + ] + }, + "agent_policy": { + "title": "Agent Policy", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "description": { + "type": "string" + }, + "monitoring_enabled": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "metrics", + "logs" + ] + } + }, + "keep_monitoring_alive": { + "description": "When set to true, monitoring will be enabled but logs/metrics collection will be disabled", + "type": "boolean", + "nullable": true + }, + "data_output_id": { + "type": "string", + "nullable": true + }, + "monitoring_output_id": { + "type": "string", + "nullable": true + }, + "fleet_server_host_id": { + "type": "string", + "nullable": true + }, + "download_source_id": { + "type": "string", + "nullable": true + }, + "unenroll_timeout": { + "type": "integer" + }, + "inactivity_timeout": { + "type": "integer" + }, + "package_policies": { + "description": "This field is present only when retrieving a single agent policy, or when retrieving a list of agent policies with the ?full=true parameter", + "type": "array", + "items": { + "$ref": "#/components/schemas/package_policy" + } + }, + "updated_on": { + "type": "string", + "format": "date-time" + }, + "updated_by": { + "type": "string" + }, + "revision": { + "type": "number" + }, + "agents": { + "type": "number" + }, + "unprivileged_agents": { + "type": "number" + }, + "agent_features": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + }, + "required": [ + "name", + "enabled" + ] + } + }, + "is_protected": { + "description": "Indicates whether the agent policy has tamper protection enabled. Default false.", + "type": "boolean" + }, + "overrides": { + "type": "object", + "description": "Override settings that are defined in the agent policy. Input settings cannot be overridden. The override option should be used only in unusual circumstances and not as a routine procedure.", + "nullable": true + }, + "advanced_settings": { + "type": "object", + "description": "Advanced settings stored in the agent policy, e.g. agent_limits_go_max_procs", + "nullable": true + }, + "supports_agentless": { + "type": "boolean", + "description": "Indicates whether the agent policy supports agentless integrations. Only allowed in a serverless environment." + }, + "global_data_tags": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ] + }, + "description": "User defined data tags that are added to all of the inputs. The values can be strings or numbers." + } + } + }, + "required": [ + "id", + "status", + "name", + "namespace" + ] + }, + "agent_policy_create_request": { + "title": "Create agent policy request", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "description": { + "type": "string" + }, + "monitoring_enabled": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "metrics", + "logs" + ] + } + }, + "data_output_id": { + "type": "string", + "nullable": true + }, + "monitoring_output_id": { + "type": "string", + "nullable": true + }, + "fleet_server_host_id": { + "type": "string", + "nullable": true + }, + "download_source_id": { + "type": "string", + "nullable": true + }, + "unenroll_timeout": { + "type": "integer" + }, + "inactivity_timeout": { + "type": "integer" + }, + "agent_features": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + }, + "required": [ + "name", + "enabled" + ] + } + }, + "is_protected": { + "type": "boolean" + }, + "force": { + "type": "boolean", + "description": "Force agent policy creation even if packages are not verified." + }, + "global_data_tags": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ] + }, + "description": "User defined data tags that are added to all of the inputs. The values can be strings or numbers." + } + } + }, + "required": [ + "name", + "namespace" + ] + }, + "agent_policy_update_request": { + "title": "Update agent policy request", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "description": { + "type": "string" + }, + "monitoring_enabled": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "metrics", + "logs" + ] + } + }, + "data_output_id": { + "type": "string", + "nullable": true + }, + "monitoring_output_id": { + "type": "string", + "nullable": true + }, + "fleet_server_host_id": { + "type": "string", + "nullable": true + }, + "download_source_id": { + "type": "string", + "nullable": true + }, + "global_data_tags": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ] + }, + "description": "User defined data tags that are added to all of the inputs. The values can be strings or numbers." + } + }, + "unenroll_timeout": { + "type": "integer" + }, + "inactivity_timeout": { + "type": "integer" + }, + "agent_features": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + }, + "required": [ + "name", + "enabled" + ] + } + }, + "is_protected": { + "type": "boolean" + }, + "force": { + "type": "boolean", + "description": "Force agent policy creation even if packages are not verified." + } + }, + "required": [ + "name", + "namespace" + ] + }, + "full_agent_policy_output": { + "title": "Full agent policy", + "type": "object", + "properties": { + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "ca_sha256": { + "type": "string", + "nullable": true + }, + "proxy_url": { + "type": "string" + }, + "proxy_headers": {}, + "type": {}, + "additionalProperties": { + "type": "object", + "properties": { + "text": {} + } + } + }, + "required": [ + "type", + "hosts", + "ca_sha256" + ] + }, + "full_agent_policy_output_permissions": { + "title": "Full agent policy output permissions", + "additionalProperties": { + "type": "object", + "properties": { + "packagePolicyName": { + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "cluster": { + "type": "array", + "items": { + "type": "string" + } + }, + "indices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + }, + "privileges": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "full_agent_policy": { + "title": "Full agent policy", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "outputs": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/full_agent_policy_output" + } + }, + "output_permissions": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "output": { + "type": "integer" + }, + "data": { + "$ref": "#/components/schemas/full_agent_policy_output_permissions" + } + } + } + }, + "fleet": { + "oneOf": [ + { + "type": "object", + "properties": { + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "proxy_url": { + "type": "string" + }, + "proxy_headers": {}, + "ssl": { + "type": "object", + "properties": { + "verification_mode": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + }, + "certificate_authorities": { + "type": "array", + "items": { + "type": "string" + } + }, + "renegotiation": { + "type": "string" + } + } + } + } + }, + { + "type": "object", + "properties": { + "kibana": { + "type": "object", + "properties": { + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "protocol": { + "type": "string" + }, + "path": { + "type": "string" + } + } + } + } + } + ] + }, + "inputs": { + "type": "string" + }, + "revision": { + "type": "number" + }, + "agent": { + "type": "string", + "nullable": true + }, + "secret_references": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + }, + "required": [ + "id", + "outputs", + "inputs" + ] + }, + "agent_policy_full": { + "title": "Agent policy full response", + "type": "object", + "oneOf": [ + { + "type": "object", + "properties": { + "item": { + "type": "string" + } + } + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/components/schemas/full_agent_policy" + } + } + } + ] + }, + "data_stream": { + "title": "Data stream", + "type": "object", + "properties": { + "index": { + "type": "string" + }, + "dataset": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "type": { + "type": "string" + }, + "package": { + "type": "string" + }, + "package_version": { + "type": "string" + }, + "last_activity_ms": { + "type": "number" + }, + "size_in_bytes": { + "type": "number" + }, + "size_in_bytes_formatted": { + "type": "string" + }, + "dashboard": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + } + } + } + } + } + }, + "enrollment_api_key": { + "title": "Enrollment API key", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "api_key_id": { + "type": "string" + }, + "api_key": { + "type": "string" + }, + "name": { + "type": "string" + }, + "active": { + "type": "boolean" + }, + "policy_id": { + "type": "string" + }, + "created_at": { + "type": "string" + } + }, + "required": [ + "id", + "api_key_id", + "api_key", + "active", + "created_at" + ] + }, + "package_policy_request": { + "title": "Package Policy Request", + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Package policy unique identifier" + }, + "name": { + "type": "string", + "description": "Package policy name (should be unique)", + "example": "nginx-123" + }, + "description": { + "type": "string", + "description": "Package policy description", + "example": "my description" + }, + "namespace": { + "type": "string", + "description": "The package policy namespace. Leave blank to inherit the agent policy's namespace.", + "example": "customnamespace" + }, + "policy_id": { + "type": "string", + "description": "Agent policy ID where that package policy will be added", + "example": "agent-policy-id", + "deprecated": true + }, + "policy_ids": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Agent policy IDs where that package policy will be added", + "example": [ + "agent-policy-id" + ] + }, + "package": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Package name", + "example": "nginx" + }, + "version": { + "type": "string", + "description": "Package version", + "example": "1.6.0" + } + }, + "required": [ + "name", + "version" + ] + }, + "vars": { + "type": "object", + "description": "Package root level variable (see integration documentation for more information)" + }, + "inputs": { + "type": "object", + "description": "Package policy inputs (see integration documentation to know what inputs are available)", + "example": { + "nginx-logfile": { + "enabled": true, + "streams": { + "nginx.access": { + "enabled": true, + "vars": { + "paths": [ + "/var/log/nginx/access.log*" + ], + "tags": [ + "nginx-access" + ], + "preserve_original_event": false, + "ignore_older": "72h" + } + } + } + } + }, + "additionalProperties": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean", + "description": "enable or disable that input, (default to true)" + }, + "vars": { + "type": "object", + "description": "Input level variable (see integration documentation for more information)" + }, + "streams": { + "type": "object", + "description": "Input streams (see integration documentation to know what streams are available)", + "additionalProperties": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean", + "description": "enable or disable that stream, (default to true)" + }, + "vars": { + "type": "object", + "description": "Stream level variable (see integration documentation for more information)" + } + } + } + } + } + } + }, + "overrides": { + "type": "object", + "properties": { + "inputs": { + "type": "object" + } + }, + "description": "Override settings that are defined in the package policy. The override option should be used only in unusual circumstances and not as a routine procedure.", + "nullable": true + }, + "force": { + "type": "boolean", + "description": "Force package policy creation even if package is not verified, or if the agent policy is managed." + } + }, + "required": [ + "name", + "package" + ] + }, + "upgrade_diff": { + "title": "Package policy Upgrade dryrun", + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/components/schemas/package_policy" + }, + { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/new_package_policy" + }, + { + "type": "object", + "properties": { + "errors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + }, + "missingVars": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ] + } + ] + } + }, + "full_agent_policy_input_stream": { + "title": "Full agent policy input stream", + "allOf": [ + { + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "string" + }, + "data_stream": { + "type": "object", + "properties": { + "dataset": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "dataset", + "type" + ] + } + }, + "required": [ + "id", + "data_stream" + ] + } + ] + }, + "full_agent_policy_input": { + "title": "Full agent policy input", + "allOf": [ + { + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "revision": { + "type": "number" + }, + "type": { + "type": "string" + }, + "data_stream": { + "type": "object", + "properties": { + "namespace": { + "type": "string" + } + }, + "required": [ + "namespace" + ] + }, + "use_output": { + "type": "string" + }, + "meta": { + "type": "object", + "additionalProperties": true, + "properties": { + "package": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "name", + "version" + ] + } + } + }, + "streams": { + "$ref": "#/components/schemas/full_agent_policy_input_stream" + } + }, + "required": [ + "id", + "name", + "revision", + "type", + "data_stream", + "use_output" + ] + } + ] + }, + "upgrade_agent_diff": { + "title": "Package policy Upgrade dryrun", + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/full_agent_policy_input" + } + } + }, + "output_create_request_elasticsearch": { + "title": "elasticsearch", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_default_monitoring": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "elasticsearch" + ] + }, + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "ca_sha256": { + "type": "string" + }, + "ca_trusted_fingerprint": { + "type": "string" + }, + "config": { + "type": "object" + }, + "preset": { + "type": "string", + "enum": [ + "balanced", + "custom", + "throughput", + "scale", + "latency" + ] + }, + "config_yaml": { + "type": "string" + }, + "ssl": { + "type": "object", + "properties": { + "certificate_authorities": { + "type": "array", + "items": { + "type": "string" + } + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + } + } + }, + "proxy_id": { + "type": "string" + }, + "shipper": { + "type": "object", + "properties": { + "disk_queue_enabled": { + "type": "boolean" + }, + "disk_queue_path": { + "type": "string" + }, + "disk_queue_max_size": { + "type": "number" + }, + "disk_queue_encryption_enabled": { + "type": "boolean" + }, + "disk_queue_compression_enabled": { + "type": "boolean" + }, + "compression_level": { + "type": "number" + }, + "loadbalance": { + "type": "boolean" + } + } + } + }, + "required": [ + "name" + ] + }, + "output_create_request_kafka": { + "title": "kafka", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_default_monitoring": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "kafka" + ] + }, + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "ca_sha256": { + "type": "string" + }, + "ca_trusted_fingerprint": { + "type": "string" + }, + "config": { + "type": "object" + }, + "config_yaml": { + "type": "string" + }, + "ssl": { + "type": "object", + "properties": { + "certificate_authorities": { + "type": "array", + "items": { + "type": "string" + } + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + }, + "verification_mode": { + "type": "string", + "enum": [ + "none", + "full", + "certificate", + "strict" + ] + } + } + }, + "proxy_id": { + "type": "string" + }, + "shipper": { + "type": "object", + "properties": { + "disk_queue_enabled": { + "type": "boolean" + }, + "disk_queue_path": { + "type": "string" + }, + "disk_queue_max_size": { + "type": "number" + }, + "disk_queue_encryption_enabled": { + "type": "boolean" + }, + "disk_queue_compression_enabled": { + "type": "boolean" + }, + "compression_level": { + "type": "number" + }, + "loadbalance": { + "type": "boolean" + } + } + }, + "version": { + "type": "string" + }, + "key": { + "type": "string" + }, + "compression": { + "type": "string" + }, + "compression_level": { + "type": "number" + }, + "client_id": { + "type": "string" + }, + "auth_type": { + "type": "string" + }, + "connection_type": { + "type": "string", + "enum": [ + "plaintext", + "encryption" + ] + }, + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + "sasl": { + "type": "object", + "properties": { + "mechanism": { + "type": "string" + } + } + }, + "partition": { + "type": "string" + }, + "random": { + "type": "object", + "properties": { + "group_events": { + "type": "number" + } + } + }, + "round_robin": { + "type": "object", + "properties": { + "group_events": { + "type": "number" + } + } + }, + "topic": { + "type": "string" + }, + "topics": { + "deprecated": true, + "description": "Use topic instead.", + "type": "array", + "items": { + "type": "object", + "properties": { + "topic": { + "type": "string" + }, + "when": { + "deprecated": true, + "description": "Deprecated, kafka output do not support conditionnal topics anymore.", + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "condition": { + "type": "string" + } + } + } + } + } + }, + "headers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + }, + "timeout": { + "type": "number" + }, + "broker_timeout": { + "type": "number" + }, + "required_acks": { + "type": "number" + }, + "secrets": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "ssl": { + "type": "object", + "properties": { + "key": { + "type": "string" + } + } + } + } + } + }, + "required": [ + "name", + "type", + "topics", + "auth_type", + "hosts" + ] + }, + "output_create_request_logstash": { + "title": "logstash", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_default_monitoring": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "logstash" + ] + }, + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "ca_sha256": { + "type": "string" + }, + "ca_trusted_fingerprint": { + "type": "string" + }, + "config": { + "type": "object" + }, + "config_yaml": { + "type": "string" + }, + "ssl": { + "type": "object", + "properties": { + "certificate_authorities": { + "type": "array", + "items": { + "type": "string" + } + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + } + } + }, + "proxy_id": { + "type": "string" + }, + "shipper": { + "type": "object", + "properties": { + "disk_queue_enabled": { + "type": "boolean" + }, + "disk_queue_path": { + "type": "string" + }, + "disk_queue_max_size": { + "type": "number" + }, + "disk_queue_encryption_enabled": { + "type": "boolean" + }, + "disk_queue_compression_enabled": { + "type": "boolean" + }, + "compression_level": { + "type": "number" + }, + "loadbalance": { + "type": "boolean" + } + } + }, + "secrets": { + "type": "object", + "properties": { + "ssl": { + "type": "object", + "properties": { + "key": { + "type": "string" + } + } + } + } + } + }, + "required": [ + "name", + "hosts", + "type" + ] + }, + "output_create_request_remote_elasticsearch": { + "title": "remote_elasticsearch", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_default_monitoring": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "remote_elasticsearch" + ] + }, + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "service_token": { + "type": "string" + }, + "secrets": { + "type": "object", + "properties": { + "service_token": { + "type": "string" + } + } + } + }, + "required": [ + "name" + ] + }, + "output_create_request": { + "title": "Output", + "oneOf": [ + { + "$ref": "#/components/schemas/output_create_request_elasticsearch" + }, + { + "$ref": "#/components/schemas/output_create_request_kafka" + }, + { + "$ref": "#/components/schemas/output_create_request_logstash" + }, + { + "$ref": "#/components/schemas/output_create_request_remote_elasticsearch" + } + ], + "discriminator": { + "propertyName": "type", + "mapping": { + "elasticsearch": "#/components/schemas/output_create_request_elasticsearch", + "kafka": "#/components/schemas/output_create_request_kafka", + "logstash": "#/components/schemas/output_create_request_logstash", + "remote_elasticsearch": "#/components/schemas/output_create_request_remote_elasticsearch" + } + } + }, + "output_update_request_elasticsearch": { + "title": "elasticsearch", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_default_monitoring": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "elasticsearch" + ] + }, + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "ca_sha256": { + "type": "string" + }, + "ca_trusted_fingerprint": { + "type": "string" + }, + "config": { + "type": "object" + }, + "preset": { + "type": "string", + "enum": [ + "balanced", + "custom", + "throughput", + "scale", + "latency" + ] + }, + "config_yaml": { + "type": "string" + }, + "ssl": { + "type": "object", + "properties": { + "certificate_authorities": { + "type": "array", + "items": { + "type": "string" + } + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + } + } + }, + "proxy_id": { + "type": "string" + }, + "shipper": { + "type": "object", + "properties": { + "disk_queue_enabled": { + "type": "boolean" + }, + "disk_queue_path": { + "type": "string" + }, + "disk_queue_max_size": { + "type": "number" + }, + "disk_queue_encryption_enabled": { + "type": "boolean" + }, + "disk_queue_compression_enabled": { + "type": "boolean" + }, + "compression_level": { + "type": "number" + }, + "loadbalance": { + "type": "boolean" + } + } + } + }, + "required": [ + "name", + "hosts", + "type" + ] + }, + "output_update_request_kafka": { + "title": "kafka", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_default_monitoring": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "kafka" + ] + }, + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "ca_sha256": { + "type": "string" + }, + "ca_trusted_fingerprint": { + "type": "string" + }, + "config": { + "type": "object" + }, + "config_yaml": { + "type": "string" + }, + "ssl": { + "type": "object", + "properties": { + "certificate_authorities": { + "type": "array", + "items": { + "type": "string" + } + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + }, + "verification_mode": { + "type": "string", + "enum": [ + "none", + "full", + "certificate", + "strict" + ] + } + } + }, + "proxy_id": { + "type": "string" + }, + "shipper": { + "type": "object", + "properties": { + "disk_queue_enabled": { + "type": "boolean" + }, + "disk_queue_path": { + "type": "string" + }, + "disk_queue_max_size": { + "type": "number" + }, + "disk_queue_encryption_enabled": { + "type": "boolean" + }, + "disk_queue_compression_enabled": { + "type": "boolean" + }, + "compression_level": { + "type": "number" + }, + "loadbalance": { + "type": "boolean" + } + } + }, + "version": { + "type": "string" + }, + "key": { + "type": "string" + }, + "compression": { + "type": "string" + }, + "compression_level": { + "type": "number" + }, + "client_id": { + "type": "string" + }, + "auth_type": { + "type": "string" + }, + "connection_type": { + "type": "string", + "enum": [ + "plaintext", + "encryption" + ] + }, + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + "sasl": { + "type": "object", + "properties": { + "mechanism": { + "type": "string" + } + } + }, + "partition": { + "type": "string" + }, + "random": { + "type": "object", + "properties": { + "group_events": { + "type": "number" + } + } + }, + "round_robin": { + "type": "object", + "properties": { + "group_events": { + "type": "number" + } + } + }, + "topic": { + "type": "string" + }, + "topics": { + "deprecated": true, + "description": "Use topic instead.", + "type": "array", + "items": { + "type": "object", + "properties": { + "topic": { + "type": "string" + }, + "when": { + "deprecated": true, + "description": "Deprecated, kafka output do not support conditionnal topics anymore.", + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "condition": { + "type": "string" + } + } + } + } + } + }, + "headers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + }, + "timeout": { + "type": "number" + }, + "broker_timeout": { + "type": "number" + }, + "required_acks": { + "type": "number" + } + }, + "required": [ + "name" + ] + }, + "output_update_request_logstash": { + "title": "logstash", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "is_default": { + "type": "boolean" + }, + "is_default_monitoring": { + "type": "boolean" + }, + "is_internal": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "logstash" + ] + }, + "hosts": { + "type": "array", + "items": { + "type": "string" + } + }, + "ca_sha256": { + "type": "string" + }, + "ca_trusted_fingerprint": { + "type": "string" + }, + "config": { + "type": "object" + }, + "config_yaml": { + "type": "string" + }, + "ssl": { + "type": "object", + "properties": { + "certificate_authorities": { + "type": "array", + "items": { + "type": "string" + } + }, + "certificate": { + "type": "string" + }, + "key": { + "type": "string" + } + } + }, + "proxy_id": { + "type": "string" + }, + "shipper": { + "type": "object", + "properties": { + "disk_queue_enabled": { + "type": "boolean" + }, + "disk_queue_path": { + "type": "string" + }, + "disk_queue_max_size": { + "type": "number" + }, + "disk_queue_encryption_enabled": { + "type": "boolean" + }, + "disk_queue_compression_enabled": { + "type": "boolean" + }, + "compression_level": { + "type": "number" + }, + "loadbalance": { + "type": "boolean" + } + } + } + }, + "required": [ + "name" + ] + }, + "output_update_request": { + "title": "Output", + "oneOf": [ + { + "$ref": "#/components/schemas/output_update_request_elasticsearch" + }, + { + "$ref": "#/components/schemas/output_update_request_kafka" + }, + { + "$ref": "#/components/schemas/output_update_request_logstash" + } + ], + "discriminator": { + "propertyName": "type", + "mapping": { + "elasticsearch": "#/components/schemas/output_update_request_elasticsearch", + "kafka": "#/components/schemas/output_update_request_kafka", + "logstash": "#/components/schemas/output_update_request_logstash" + } + } + } + } + }, + "security": [ + { + "basicAuth": [] + } + ] +} diff --git a/tools/fleet_gen.go b/tools/fleet_gen.go index 72e71abea..793dcb87c 100644 --- a/tools/fleet_gen.go +++ b/tools/fleet_gen.go @@ -1,4 +1,6 @@ package tools -//go:generate go run ../generated/fleet/getschema.go -v v8.15.0 -o ../generated/fleet/fleet-filtered.json +// //go:generate go run ../generated/fleet/getschema.go -v v8.15.0 -o ../generated/fleet/fleet-filtered.json + +//go:generate go run ../generated/fleet/getschema.go -i ./fleet-spec.json -o ../generated/fleet/fleet-filtered.json //go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -package=fleet -generate=types,client -o ../generated/fleet/fleet.gen.go ../generated/fleet/fleet-filtered.json From 351b89063e5c116bdb333308752fa65dabcad67e Mon Sep 17 00:00:00 2001 From: mholttech Date: Tue, 3 Sep 2024 12:52:57 -0700 Subject: [PATCH 10/11] Remove unused variables and update CHANGELOG --- CHANGELOG.md | 2 +- internal/fleet/agent_policy_resource.go | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7345f618..352f876d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Add support for data_stream `lifecycle` template settings ([#724](https://github.com/elastic/terraform-provider-elasticstack/pull/724)) - Fix a provider panic when `elasticstack_kibana_action_connector` reads a non-existant connector ([#729](https://github.com/elastic/terraform-provider-elasticstack/pull/729)) - Add support for `remote_indicies` to `elasticstack_elasticsearch_security_role` & `elasticstack_kibana_security_role` (#723)[https://github.com/elastic/terraform-provider-elasticstack/pull/723] -- Add support for global data tags in agent policy creation and update (#730)[https://github.com/elastic/terraform-provider-elasticstack/pull/730] +- Added support for global data tags in agent policy creation and update. Upgraded the generated Fleet API to version 8.15.0. (#730)[https://github.com/elastic/terraform-provider-elasticstack/pull/730] ## [0.11.6] - 2024-08-20 diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index 5feeb7c90..db1fb74bb 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -289,16 +289,6 @@ func resourceAgentPolicyRead(ctx context.Context, d *schema.ResourceData, meta i return diags } - apiClient, diags := clients.NewApiClientFromSDKResource(d, meta) - if diags.HasError() { - return diags - } - - serverVersion, diags := apiClient.ServerVersion(ctx) - if diags.HasError() { - return diags - } - agentPolicy, diags := fleet.ReadAgentPolicy(ctx, fleetClient, d.Id()) if diags.HasError() { return diags From c5418b207d6065b93bb0b6a3cc4bb31bdd8e9d5c Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Wed, 4 Sep 2024 08:25:16 +1000 Subject: [PATCH 11/11] lint --- internal/fleet/agent_policy_resource.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/fleet/agent_policy_resource.go b/internal/fleet/agent_policy_resource.go index db1fb74bb..f186f3f82 100644 --- a/internal/fleet/agent_policy_resource.go +++ b/internal/fleet/agent_policy_resource.go @@ -173,10 +173,16 @@ func resourceAgentPolicyCreate(ctx context.Context, d *schema.ResourceData, meta gdt := []map[string]fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{} for key, value := range tagMap { name := fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{} - name.FromAgentPolicyCreateRequestGlobalDataTags0(key) + err := name.FromAgentPolicyCreateRequestGlobalDataTags0(key) + if err != nil { + return diag.FromErr(fmt.Errorf("failed to parse global_data_tags key [%s]: %w", key, err)) + } val := fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{} - val.FromAgentPolicyCreateRequestGlobalDataTags0(value.(string)) + err = val.FromAgentPolicyCreateRequestGlobalDataTags0(value.(string)) + if err != nil { + return diag.FromErr(fmt.Errorf("failed to parse global_data_tags value [%s]: %w", value.(string), err)) + } gdt = append(gdt, map[string]fleetapi.AgentPolicyCreateRequest_GlobalDataTags_AdditionalProperties{ "name": name,