Skip to content

Commit

Permalink
Migrate remaining routes
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Aug 1, 2019
1 parent 89b1f9e commit e883295
Show file tree
Hide file tree
Showing 48 changed files with 640 additions and 464 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import styled from 'styled-components';
import { ServiceListAPIResponse } from '../../../../../server/lib/services/get_services';
import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
import { ServiceListAPIResponse } from '../../../../../server/routes/services/service_list_route';
import { fontSizes, truncate } from '../../../../style/variables';
import { asDecimal, asMillis } from '../../../../utils/formatters';
import { APMLink } from '../../../shared/Links/apm/APMLink';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
deleteAgentConfiguration,
updateAgentConfiguration,
createAgentConfiguration
} from '../../../../services/rest/apm/settings';
} from '../../../../services/rest/apm/agent_configuration';
import { ENVIRONMENT_NOT_DEFINED } from '../../../../../common/environment_filter_values';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import {
EuiLink
} from '@elastic/eui';
import { isEmpty } from 'lodash';
import { loadAgentConfigurationList } from '../../../services/rest/apm/settings';
import { loadAgentConfigurationList } from '../../../services/rest/apm/agent_configuration';
import { useFetcher } from '../../../hooks/useFetcher';
import { ITableColumn, ManagedTable } from '../../shared/ManagedTable';
import { AgentConfigurationListAPIResponse } from '../../../../server/lib/settings/agent_configuration/list_configurations';
import { AddSettingsFlyout } from './AddSettings/AddSettingFlyout';
import { APMLink } from '../../shared/Links/apm/APMLink';
import { LoadingStatePrompt } from '../../shared/LoadingStatePrompt';
import { AgentConfigurationListAPIResponse } from '../../../../server/routes/agent_configuration/agent_configuration_list_route';

export type Config = AgentConfigurationListAPIResponse[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
zipObject
} from 'lodash';
import { idx } from '@kbn/elastic-idx';
import { TraceAPIResponse } from '../../../../../../../../server/lib/traces/get_trace';
import { StringMap } from '../../../../../../../../typings/common';
import { Span } from '../../../../../../../../typings/es_schemas/ui/Span';
import { Transaction } from '../../../../../../../../typings/es_schemas/ui/Transaction';
import { TraceAPIResponse } from '../../../../../../../../server/routes/traces/trace_route';

interface IWaterfallIndex {
[key: string]: IWaterfallItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,48 @@ export function DatePicker() {

return (
<EuiSuperDatePicker
commonlyUsedRanges={[
{
start: 'now-15m',
end: 'now',
label: 'Last 15 minutes'
},
{
start: 'now-30m',
end: 'now',
label: 'Last 30 minutes'
},
{
start: 'now-1h',
end: 'now',
label: 'Last 1 hour'
},
{
start: 'now-24h',
end: 'now',
label: 'Last 24 hours'
},
{
start: 'now-7d',
end: 'now',
label: 'Last 7 days'
},
{
start: 'now-30d',
end: 'now',
label: 'Last 30 days'
},
{
start: 'now-90d',
end: 'now',
label: 'Last 90 days'
},
{
start: 'now-1y',
end: 'now',
label: 'Last 1 year'
}
]}
start={rangeFrom}
end={rangeTo}
isPaused={refreshPaused}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { UpdateAgentConfigurationAPIResponse } from '../../../../server/lib/settings/agent_configuration/update_configuration';
import { callApi } from '../callApi';
import { callApmApi } from '../callApi';
import { AgentConfigurationIntake } from '../../../../server/lib/settings/agent_configuration/configuration_types';
import { AgentConfigurationServicesAPIResponse } from '../../../../server/lib/settings/agent_configuration/get_service_names';
import { CreateAgentConfigurationAPIResponse } from '../../../../server/lib/settings/agent_configuration/create_configuration';
import { AgentConfigurationListAPIResponse } from '../../../../server/lib/settings/agent_configuration/list_configurations';
import { AgentConfigurationEnvironmentsAPIResponse } from '../../../../server/lib/settings/agent_configuration/get_environments';
import { agentConfigurationListRoute } from '../../../../server/routes/agent_configuration/agent_configuration_list_route';
import { environmentsRoute } from '../../../../server/routes/agent_configuration/environments_route';
import { serviceNamesRoute } from '../../../../server/routes/agent_configuration/service_names_route';
import { createAgentConfigurationRoute } from '../../../../server/routes/agent_configuration/create_agent_configuration_route';
import { updateAgentConfigurationRoute } from '../../../../server/routes/agent_configuration/update_agent_configuration_route';

export async function loadAgentConfigurationServices() {
return callApi<AgentConfigurationServicesAPIResponse>({
return callApmApi<typeof serviceNamesRoute>({
pathname: `/api/apm/settings/agent-configuration/services`
});
}
Expand All @@ -23,15 +23,15 @@ export async function loadAgentConfigurationEnvironments({
}: {
serviceName: string;
}) {
return callApi<AgentConfigurationEnvironmentsAPIResponse>({
return callApmApi<typeof environmentsRoute>({
pathname: `/api/apm/settings/agent-configuration/services/${serviceName}/environments`
});
}

export async function createAgentConfiguration(
configuration: AgentConfigurationIntake
) {
return callApi<CreateAgentConfigurationAPIResponse>({
return callApmApi<typeof createAgentConfigurationRoute>({
pathname: `/api/apm/settings/agent-configuration/new`,
method: 'POST',
body: JSON.stringify(configuration)
Expand All @@ -42,22 +42,22 @@ export async function updateAgentConfiguration(
configurationId: string,
configuration: AgentConfigurationIntake
) {
return callApi<UpdateAgentConfigurationAPIResponse>({
return callApmApi<typeof updateAgentConfigurationRoute>({
pathname: `/api/apm/settings/agent-configuration/${configurationId}`,
method: 'PUT',
body: JSON.stringify(configuration)
});
}

export async function deleteAgentConfiguration(configId: string) {
return callApi({
return callApmApi({
pathname: `/api/apm/settings/agent-configuration/${configId}`,
method: 'DELETE'
});
}

export async function loadAgentConfigurationList() {
return callApi<AgentConfigurationListAPIResponse>({
return callApmApi<typeof agentConfigurationListRoute>({
pathname: `/api/apm/settings/agent-configuration`
});
}
22 changes: 12 additions & 10 deletions x-pack/legacy/plugins/apm/public/services/rest/apm/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { ServiceAgentNameAPIResponse } from '../../../../server/lib/services/get_service_agent_name';
import { ServiceListAPIResponse } from '../../../../server/lib/services/get_services';
import { callApi } from '../callApi';
import { callApmApi } from '../callApi';
import { UIFilters } from '../../../../typings/ui-filters';
import { ServiceTransactionTypesAPIResponse } from '../../../../server/lib/services/get_service_transaction_types';
import { serviceListRoute } from '../../../../server/routes/services/service_list_route';
import { serviceAgentNameRoute } from '../../../../server/routes/services/service_agent_name_route';
import { serviceTransactionTypesRoute } from '../../../../server/routes/services/service_transaction_types_routes';

export async function loadServiceList({
start,
Expand All @@ -19,7 +19,7 @@ export async function loadServiceList({
end: string;
uiFilters: UIFilters;
}) {
return callApi<ServiceListAPIResponse>({
return callApmApi<typeof serviceListRoute>({
pathname: `/api/apm/services`,
query: {
start,
Expand All @@ -38,11 +38,12 @@ export async function loadServiceAgentName({
start: string;
end: string;
}) {
const { agentName } = await callApi<ServiceAgentNameAPIResponse>({
const { agentName } = await callApmApi<typeof serviceAgentNameRoute>({
pathname: `/api/apm/services/${serviceName}/agent_name`,
query: {
start,
end
end,
uiFilters: undefined // TODO: should uiFilters be required like this?
}
});

Expand All @@ -58,13 +59,14 @@ export async function loadServiceTransactionTypes({
start: string;
end: string;
}) {
const { transactionTypes } = await callApi<
ServiceTransactionTypesAPIResponse
const { transactionTypes } = await callApmApi<
typeof serviceTransactionTypesRoute
>({
pathname: `/api/apm/services/${serviceName}/transaction_types`,
query: {
start,
end
end,
uiFilters: undefined // TODO: should uiFilters be required like this?
}
});
return transactionTypes;
Expand Down
13 changes: 7 additions & 6 deletions x-pack/legacy/plugins/apm/public/services/rest/apm/traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TraceAPIResponse } from '../../../../server/lib/traces/get_trace';
import { callApi } from '../callApi';
import { callApmApi } from '../callApi';
import { UIFilters } from '../../../../typings/ui-filters';
import { TransactionGroupListAPIResponse } from '../../../../server/routes/transaction_groups/transaction_group_list_route';
import { traceListRoute } from '../../../../server/routes/traces/trace_list_route';
import { traceRoute } from '../../../../server/routes/traces/trace_route';

export async function loadTrace({
traceId,
Expand All @@ -18,11 +18,12 @@ export async function loadTrace({
start: string;
end: string;
}) {
return callApi<TraceAPIResponse>({
return callApmApi<typeof traceRoute>({
pathname: `/api/apm/traces/${traceId}`,
query: {
start,
end
end,
uiFilters: undefined // TODO: should uiFilters be required like this?
}
});
}
Expand All @@ -36,7 +37,7 @@ export async function loadTraceList({
end: string;
uiFilters: UIFilters;
}) {
return callApi<TransactionGroupListAPIResponse>({
return callApmApi<typeof traceListRoute>({
pathname: '/api/apm/traces',
query: {
start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EnvironmentUIFilterAPIResponse } from '../../../../server/lib/ui_filters/get_environments';
import { callApi } from '../callApi';
import { callApmApi } from '../callApi';
import { environmentsRoute } from '../../../../server/routes/ui_filters/environments_route';

export async function loadEnvironmentsFilter({
serviceName,
Expand All @@ -16,7 +16,7 @@ export async function loadEnvironmentsFilter({
start: string;
end: string;
}) {
return callApi<EnvironmentUIFilterAPIResponse>({
return callApmApi<typeof environmentsRoute>({
pathname: '/api/apm/ui_filters/environments',
query: {
start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type APMRequest<Q extends Record<string, any> | unknown> = {
export interface DefaultQueryParams {
start: string;
end: string;
uiFilters: string;
uiFilters: string | undefined;
}

interface APMRequestQuery {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import {
SERVICE_AGENT_NAME,
SERVICE_NAME
} from '../../../common/elasticsearch_fieldnames';
import { PromiseReturnType } from '../../../typings/common';
import { rangeFilter } from '../helpers/range_filter';
import { Setup } from '../helpers/setup_request';

export type ServiceAgentNameAPIResponse = PromiseReturnType<
typeof getServiceAgentName
>;
export async function getServiceAgentName(serviceName: string, setup: Setup) {
const { start, end, client, config } = setup;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import {
SERVICE_NAME,
TRANSACTION_TYPE
} from '../../../common/elasticsearch_fieldnames';
import { PromiseReturnType } from '../../../typings/common';
import { rangeFilter } from '../helpers/range_filter';
import { Setup } from '../helpers/setup_request';

export type ServiceTransactionTypesAPIResponse = PromiseReturnType<
typeof getServiceTransactionTypes
>;
export async function getServiceTransactionTypes(
serviceName: string,
setup: Setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import {
SERVICE_NAME,
TRANSACTION_DURATION
} from '../../../../common/elasticsearch_fieldnames';
import { PromiseReturnType } from '../../../../typings/common';
import { rangeFilter } from '../../helpers/range_filter';
import { Setup } from '../../helpers/setup_request';

export type ServiceListAPIResponse = PromiseReturnType<typeof getServicesItems>;
export async function getServicesItems(setup: Setup) {
const { start, end, uiFiltersES, client, config } = setup;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
*/

import { isEmpty } from 'lodash';
import { PromiseReturnType } from '../../../../typings/common';
import { Setup } from '../../helpers/setup_request';
import { getAgentStatus } from './get_agent_status';
import { getLegacyDataStatus } from './get_legacy_data_status';
import { getServicesItems } from './get_services_items';

export type ServiceListAPIResponse = PromiseReturnType<typeof getServices>;
export async function getServices(setup: Setup) {
const items = await getServicesItems(setup);
const hasLegacyData = await getLegacyDataStatus(setup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
*/

import { Setup } from '../../helpers/setup_request';
import { PromiseReturnType } from '../../../../typings/common';
import { AgentConfigurationIntake } from './configuration_types';

export type CreateAgentConfigurationAPIResponse = PromiseReturnType<
typeof createConfiguration
>;
export async function createConfiguration({
export async function createAgentConfiguration({
configuration,
setup
}: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Setup } from '../../helpers/setup_request';

export async function deleteConfiguration({
export async function deleteAgentConfiguration({
configurationId,
setup
}: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { PromiseReturnType } from '../../../../typings/common';
import { Setup } from '../../helpers/setup_request';
import { AgentConfiguration } from './configuration_types';

export type AgentConfigurationListAPIResponse = PromiseReturnType<
typeof listConfigurations
>;
export async function listConfigurations({ setup }: { setup: Setup }) {
export async function getAgentConfigurationList({ setup }: { setup: Setup }) {
const { client, config } = setup;

const params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@

import { getAllEnvironments } from './get_all_environments';
import { Setup } from '../../../helpers/setup_request';
import { PromiseReturnType } from '../../../../../typings/common';
import { getUnavailableEnvironments } from './get_unavailable_environments';

export type AgentConfigurationEnvironmentsAPIResponse = PromiseReturnType<
typeof getEnvironments
>;

export async function getEnvironments({
serviceName,
setup
Expand Down
Loading

0 comments on commit e883295

Please sign in to comment.