Skip to content

Commit

Permalink
[Fleet] Fleet APIs using kbn/config-schema part 3 (elastic#193698)
Browse files Browse the repository at this point in the history
## Summary

Relates elastic#184685


Added response schemas to remaining APIs:
- agent_policies
- agents, actions
- download_source
- enrollment_api_key
- epm

when this is merged, the fleet/openapi folder can be deleted (which
includes the previous version of bundled.yaml)


### 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 Oct 3, 2024
1 parent 932614a commit 28aeb68
Show file tree
Hide file tree
Showing 38 changed files with 4,439 additions and 243 deletions.
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ interface AgentBase {
policy_id?: string;
policy_revision?: number | null;
last_checkin?: string;
last_checkin_status?: 'error' | 'online' | 'degraded' | 'updating';
last_checkin_status?: 'error' | 'online' | 'degraded' | 'updating' | 'starting';
last_checkin_message?: string;
user_provided_metadata: AgentMetadata;
user_provided_metadata?: AgentMetadata;
local_metadata: AgentMetadata;
tags?: string[];
components?: FleetServerAgentComponent[];
Expand Down Expand Up @@ -272,7 +272,7 @@ export interface FleetServerAgent {
/**
* User provided metadata information for the Elastic Agent
*/
user_provided_metadata: AgentMetadata;
user_provided_metadata?: AgentMetadata;
/**
* Local metadata information for the Elastic Agent
*/
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/fleet/common/types/models/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export interface NewAgentPolicy {
enabled: boolean;
host?: string;
port?: number;
buffer?: {
enabled: boolean;
};
};
monitoring_diagnostics?: {
limit?: {
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ type RegistryOverridesToOptional = Pick<PackageSpecManifest, 'title' | 'release'
// and confirm with Registry if they are really optional. Can update types and ~4 places in code later if neccessary
interface RegistryAdditionalProperties {
assets?: string[];
download: string;
download?: string;
signature_path?: string;
path: string;
path?: string;
readme?: string;
internal?: boolean; // Registry addition[0] and EPM uses it[1] [0]: https://github.com/elastic/package-registry/blob/dd7b021893aa8d66a5a5fde963d8ff2792a9b8fa/util/package.go#L63 [1]
data_streams?: RegistryDataStream[]; // Registry addition [0] [0]: https://github.com/elastic/package-registry/blob/dd7b021893aa8d66a5a5fde963d8ff2792a9b8fa/util/package.go#L65
Expand Down Expand Up @@ -317,9 +317,9 @@ export interface AssetParts {
export type AssetTypeToParts = KibanaAssetTypeToParts & ElasticsearchAssetTypeToParts;
export type AssetsGroupedByServiceByType = Record<
Extract<ServiceName, 'kibana'>,
KibanaAssetTypeToParts
KibanaAssetTypeToParts | undefined
> &
Record<Extract<ServiceName, 'elasticsearch'>, ElasticsearchAssetTypeToParts>;
Record<Extract<ServiceName, 'elasticsearch'>, ElasticsearchAssetTypeToParts | undefined>;

export type KibanaAssetParts = AssetParts & {
service: Extract<ServiceName, 'kibana'>;
Expand Down Expand Up @@ -534,7 +534,7 @@ export type PackageInfo =
| Installable<Merge<ArchivePackage, EpmPackageAdditions>>;

export interface PackageMetadata {
has_policies: true;
has_policies: boolean;
}

export type IntegrationCardReleaseLabel = 'beta' | 'preview' | 'ga' | 'rc';
Expand Down
14 changes: 8 additions & 6 deletions x-pack/plugins/fleet/common/types/models/package_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type { RegistryElasticsearch, RegistryPolicyTemplate, RegistryVarsEntry }

// Based on https://github.com/elastic/package-spec/blob/master/versions/1/manifest.spec.yml#L8
export interface PackageSpecManifest {
format_version: string;
format_version?: string;
name: string;
title: string;
description: string;
description?: string;
version: string;
license?: 'basic';
source?: {
Expand All @@ -26,7 +26,7 @@ export interface PackageSpecManifest {
screenshots?: PackageSpecScreenshot[];
policy_templates?: RegistryPolicyTemplate[];
vars?: RegistryVarsEntry[];
owner: { github: string; type?: 'elastic' | 'partner' | 'community' };
owner: { github?: string; type?: 'elastic' | 'partner' | 'community' };
elasticsearch?: Pick<
RegistryElasticsearch,
'index_template.settings' | 'index_template.mappings' | 'index_template.data_stream'
Expand Down Expand Up @@ -113,11 +113,12 @@ export type PackageSpecCategory =
| 'workplace_search_content_source';

export interface PackageSpecConditions {
kibana: {
version: string;
kibana?: {
version?: string;
};
elastic?: {
subscription: string;
subscription?: string;
capabilities?: string[];
};
}

Expand All @@ -126,6 +127,7 @@ export interface PackageSpecIcon {
title?: string;
size?: string;
type?: string;
dark_mode?: boolean;
}

export interface PackageSpecScreenshot {
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/fleet/common/types/rest_spec/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import type { SortResults } from '@elastic/elasticsearch/lib/api/types';

import type { PackageSpecIcon } from '../models/package_spec';
import type {
AssetReference,
CategorySummaryList,
Expand Down Expand Up @@ -61,6 +62,9 @@ export interface InstalledPackage {
name: string;
title: string;
}>;
title?: string;
description?: string;
icons?: PackageSpecIcon[];
}
export interface GetInstalledPackagesResponse {
items: InstalledPackage[];
Expand Down Expand Up @@ -160,7 +164,7 @@ export interface InstallResult {
status?: InstallResultStatus;
error?: Error;
installType: InstallType;
installSource: InstallSource;
installSource?: InstallSource;
}

export interface BulkInstallPackageInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const SettingsPage: React.FC<Props> = memo(
numOfAssets: Object.entries(packageInfo.assets).reduce(
(acc, [serviceName, serviceNameValue]) =>
acc +
Object.entries(serviceNameValue).reduce(
Object.entries(serviceNameValue || {}).reduce(
(acc2, [assetName, assetNameValue]) => acc2 + assetNameValue.length,
0
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const mapToCard = ({

return {
id: `${item.type === 'ui_link' ? 'ui_link' : 'epr'}:${item.id}`,
description: item.description,
description: item.description || '',
icons: !item.icons || !item.icons.length ? [] : item.icons,
title: item.title,
url: uiInternalPathUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import type { PackageInfo } from '../../common';
export const getNumTransformAssets = (assets?: PackageInfo['assets']) => {
if (
!assets ||
!(Array.isArray(assets.elasticsearch?.transform) && assets.elasticsearch?.transform?.length > 0)
!(
Array.isArray(assets.elasticsearch?.transform) &&
(assets.elasticsearch?.transform?.length ?? 0) > 0
)
) {
return 0;
}
Expand Down
Loading

0 comments on commit 28aeb68

Please sign in to comment.