Skip to content

Commit

Permalink
[Fleet] added format parameter to agent_policies APIs (elastic#191811)
Browse files Browse the repository at this point in the history
## Summary

Closes elastic#161625

Support simplified format in `agent_policies` APIs when the response
contains `package_policies`.

API endpoints updated:
```
# Get all
GET kbn:/api/fleet/agent_policies?full=true&format=simplified
# Bulk get
POST kbn:/api/fleet/agent_policies/_bulk_get?format=simplified
     {
      "ids": ["fleet-server-policy"],
      "full": true
     }
# Get one
GET kbn:/api/fleet/agent_policies/fleet-server-policy?format=simplified
# Update
PUT kbn:/api/fleet/agent_policies/fleet-server-policy?format=simplified
    {
      "name": "Fleet Server Policy",
      "namespace": "default"
    }
# Copy
POST kbn:/api/fleet/agent_policies/fleet-server-policy/copy?format=simplified
         {
      "name": "Fleet Server Policy (copy)"
    }

# Example response

{
  "items": [
    {
      "id": "fleet-server-policy",
      "version": "WzIxMzIsMV0=",
      "description": "Fleet Server policy generated by Kibana",
      "is_default_fleet_server": true,
      "monitoring_enabled": [
        "logs",
        "metrics"
      ],
      "inactivity_timeout": 1209600,
      "schema_version": "1.1.1",
      "package_policies": [
        {
          "id": "8cb17156-d295-475e-9ec8-44ef138a5d49",
          "version": "WzIwNzYsMV0=",
          "name": "system-3",
          "namespace": "default",
          "package": {
            "name": "system",
            "title": "System",
            "version": "1.60.3",
            "requires_root": true
          },
          "enabled": true,
          "policy_id": "fleet-server-policy",
          "policy_ids": [
            "fleet-server-policy"
          ],
          "inputs": {
            "system-logfile": {
              "enabled": true,
              "streams": {
                "system.auth": {
                  "enabled": true,
                  "vars": {
                    "ignore_older": "72h",
                    "paths": [
                      "/var/log/auth.log*",
                      "/var/log/secure*"
                    ],
                    "preserve_original_event": false,
                    "tags": [
                      "system-auth"
                    ]
                  }
                },
```

Create and Delete APIs don't return package policies, so didn't change
those.
Also didn't update the
`kbn:/api/fleet/agent_policies/fleet-server-policy/full` path, it has a
different format.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
juliaElastic authored Aug 30, 2024
1 parent ee28e20 commit cd56f41
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 69 deletions.
25 changes: 23 additions & 2 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -3417,6 +3417,9 @@
{
"$ref": "#/components/parameters/kuery"
},
{
"$ref": "#/components/parameters/format"
},
{
"schema": {
"type": "boolean"
Expand Down Expand Up @@ -3488,6 +3491,9 @@
"name": "agentPolicyId",
"in": "path",
"required": true
},
{
"$ref": "#/components/parameters/format"
}
],
"get": {
Expand Down Expand Up @@ -3576,6 +3582,9 @@
"name": "agentPolicyId",
"in": "path",
"required": true
},
{
"$ref": "#/components/parameters/format"
}
],
"post": {
Expand Down Expand Up @@ -3830,7 +3839,11 @@
},
"operationId": "bulk-get-agent-policies",
"security": [],
"parameters": []
"parameters": [
{
"$ref": "#/components/parameters/format"
}
]
}
},
"/agent_policies/delete": {
Expand Down Expand Up @@ -7595,6 +7608,7 @@
},
"policy_id": {
"type": "string",
"nullable": true,
"deprecated": true
},
"policy_ids": {
Expand Down Expand Up @@ -8285,11 +8299,18 @@
"description": "The package policy namespace. Leave blank to inherit the agent policy's namespace.",
"example": "customnamespace"
},
"output_id": {
"type": "string",
"description": "Output ID to send package data to",
"example": "output-id",
"nullable": true
},
"policy_id": {
"type": "string",
"description": "Agent policy ID where that package policy will be added",
"example": "agent-policy-id",
"deprecated": true
"deprecated": true,
"nullable": true
},
"policy_ids": {
"type": "array",
Expand Down
Loading

0 comments on commit cd56f41

Please sign in to comment.