Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Add new APIs and preconfiguration for Fleet server hosts per policy #142746

Merged
merged 11 commits into from
Oct 6, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const previouslyRegisteredTypes = [
'fleet-agents',
'fleet-enrollment-api-keys',
'fleet-preconfiguration-deletion-record',
'fleet-fleet-server-host',
'graph-workspace',
'guided-setup-state',
'guided-onboarding-guide-state',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const FLEET_SERVER_HOST_SAVED_OBJECT_TYPE = 'fleet-fleet-server-host';

export const DEFAULT_FLEET_SERVER_HOST_ID = 'fleet-default-fleet-server-host';
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export * from './enrollment_api_key';
export * from './settings';
export * from './preconfiguration';
export * from './download_source';
export * from './fleet_server_policy_config';
export * from './authz';

// TODO: This is the default `index.max_result_window` ES setting, which dictates
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/fleet/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ export const OUTPUT_API_ROUTES = {
LOGSTASH_API_KEY_PATTERN: `${API_ROOT}/logstash_api_keys`,
};

// Fleet server API routes
export const FLEET_SERVER_HOST_API_ROUTES = {
LIST_PATTERN: `${API_ROOT}/fleet_server_hosts`,
CREATE_PATTERN: `${API_ROOT}/fleet_server_hosts`,
INFO_PATTERN: `${API_ROOT}/fleet_server_hosts/{itemId}`,
UPDATE_PATTERN: `${API_ROOT}/fleet_server_hosts/{itemId}`,
DELETE_PATTERN: `${API_ROOT}/fleet_server_hosts/{itemId}`,
};

// Settings API routes
export const SETTINGS_API_ROUTES = {
INFO_PATTERN: `${API_ROOT}/settings`,
Expand Down
258 changes: 255 additions & 3 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -3706,6 +3706,230 @@
}
]
}
},
"/fleet_server_hosts": {
"get": {
"summary": "Fleet Server Hosts - List",
"description": "Return a list of Fleet server host",
"tags": [],
"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"
}
}
}
}
}
}
},
"operationId": "get-fleet-server-hosts"
},
"post": {
"summary": "Fleet Server Hosts - Create",
"description": "Create a new Fleet Server Host",
"tags": [],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"item": {
"$ref": "#/components/schemas/fleet_server_host"
}
}
}
}
}
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"is_default": {
"type": "boolean"
},
"host_urls": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"name",
"host_urls"
]
}
}
}
},
"operationId": "post-fleet-server-hosts"
}
},
"/fleet_server_hosts/{itemId}": {
"get": {
"summary": "Fleet Server Hosts - Info",
"tags": [],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"item": {
"$ref": "#/components/schemas/fleet_server_host"
}
},
"required": [
"item"
]
}
}
}
}
},
"operationId": "get-one-fleet-server-hosts"
},
"parameters": [
{
"schema": {
"type": "string"
},
"name": "itemId",
"in": "path",
"required": true
}
],
"delete": {
"summary": "Fleet Server Hosts - Delete",
"operationId": "delete-fleet-server-hosts",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
},
"required": [
"id"
]
}
}
}
}
},
"parameters": [
{
"schema": {
"type": "string"
},
"name": "itemId",
"in": "path",
"required": true
},
{
"$ref": "#/components/parameters/kbn_xsrf"
}
]
},
"put": {
"summary": "Fleet Server Hosts - Update",
"operationId": "update-fleet-server-hosts",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"is_default": {
"type": "boolean"
},
"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"
]
}
}
}
}
},
"parameters": [
{
"schema": {
"type": "string"
},
"name": "itemId",
"in": "path",
"required": true
},
{
"$ref": "#/components/parameters/kbn_xsrf"
}
]
}
}
},
"components": {
Expand Down Expand Up @@ -3977,9 +4201,6 @@
"has_seen_add_data_notice": {
"type": "boolean"
},
"has_seen_fleet_migration_notice": {
"type": "boolean"
},
"fleet_server_hosts": {
"type": "array",
"items": {
Expand Down Expand Up @@ -5470,6 +5691,37 @@
"name",
"host"
]
},
"fleet_server_host": {
"title": "Fleet Server Host",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"is_default": {
"type": "boolean"
},
"is_preconfigured": {
"type": "boolean"
},
"host_urls": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"fleet_server_hosts",
"id",
"is_default",
"is_preconfigured",
"host_urls"
]
}
}
},
Expand Down
Loading