API: Support versioned frontend clients (#106545)
* Update the generator to include version * Add versioned APIs * Update imports * Prettier
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ import { getAPIBaseURL } from 'app/api/utils';
|
||||
export const BASE_URL = getAPIBaseURL('advisor.grafana.app', 'v0alpha1');
|
||||
|
||||
export const api = createApi({
|
||||
reducerPath: 'advisorAPI',
|
||||
reducerPath: 'advisorAPIv0alpha1',
|
||||
baseQuery: createBaseQuery({
|
||||
baseURL: BASE_URL,
|
||||
}),
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { generatedAPI } from './endpoints.gen';
|
||||
|
||||
export const advisorAPI = generatedAPI.enhanceEndpoints({
|
||||
export const advisorAPIv0alpha1 = generatedAPI.enhanceEndpoints({
|
||||
endpoints: {
|
||||
// Need to mutate the generated query to set the Content-Type header correctly
|
||||
updateCheck: (endpointDefinition) => {
|
||||
@@ -37,5 +37,5 @@ export const {
|
||||
useUpdateCheckMutation,
|
||||
useListCheckTypeQuery,
|
||||
useUpdateCheckTypeMutation,
|
||||
} = advisorAPI;
|
||||
} = advisorAPIv0alpha1;
|
||||
export { type Check, type CheckType } from './endpoints.gen'; // eslint-disable-line
|
||||
+1
-1
@@ -6,7 +6,7 @@ import { getAPIBaseURL } from 'app/api/utils';
|
||||
export const BASE_URL = getAPIBaseURL('folder.grafana.app', 'v1beta1');
|
||||
|
||||
export const api = createApi({
|
||||
reducerPath: 'folderAPI',
|
||||
reducerPath: 'folderAPIv1beta1',
|
||||
baseQuery: createBaseQuery({
|
||||
baseURL: BASE_URL,
|
||||
}),
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import { generatedAPI } from './endpoints.gen';
|
||||
|
||||
export const folderAPI = generatedAPI.enhanceEndpoints({});
|
||||
export const folderAPIv1beta1 = generatedAPI.enhanceEndpoints({});
|
||||
|
||||
export const { useGetFolderQuery } = folderAPI;
|
||||
export const { useGetFolderQuery } = folderAPIv1beta1;
|
||||
|
||||
// eslint-disable-next-line no-barrel-files/no-barrel-files
|
||||
export { type Folder } from './endpoints.gen';
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react';
|
||||
|
||||
import { createBaseQuery } from '../../createBaseQuery';
|
||||
import { getAPIBaseURL } from '../../utils';
|
||||
import { createBaseQuery } from 'app/api/createBaseQuery';
|
||||
import { getAPIBaseURL } from 'app/api/utils';
|
||||
|
||||
export const BASE_URL = getAPIBaseURL('iam.grafana.app', 'v0alpha1');
|
||||
|
||||
export const api = createApi({
|
||||
baseQuery: createBaseQuery({ baseURL: BASE_URL }),
|
||||
reducerPath: 'iamAPI',
|
||||
reducerPath: 'iamAPIv0alpha1',
|
||||
endpoints: () => ({}),
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { generatedAPI } from './endpoints.gen';
|
||||
|
||||
export const iamAPI = generatedAPI.enhanceEndpoints({});
|
||||
export const iamAPIv0alpha1 = generatedAPI.enhanceEndpoints({});
|
||||
|
||||
export const { useGetDisplayMappingQuery } = generatedAPI;
|
||||
+1
-1
@@ -6,7 +6,7 @@ import { getAPIBaseURL } from 'app/api/utils';
|
||||
export const BASE_URL = getAPIBaseURL('playlist.grafana.app', 'v0alpha1');
|
||||
|
||||
export const api = createApi({
|
||||
reducerPath: 'playlistAPI',
|
||||
reducerPath: 'playlistAPIv0alpha1',
|
||||
baseQuery: createBaseQuery({
|
||||
baseURL: BASE_URL,
|
||||
}),
|
||||
+1
@@ -306,6 +306,7 @@ export type Playlist = {
|
||||
/** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */
|
||||
kind?: string;
|
||||
metadata: ObjectMeta;
|
||||
/** Spec is the spec of the Playlist */
|
||||
spec: PlaylistSpec;
|
||||
status: PlaylistStatus;
|
||||
};
|
||||
+6
-6
@@ -1,13 +1,13 @@
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
|
||||
import { notifyApp } from '../../../core/actions';
|
||||
import { createSuccessNotification } from '../../../core/copy/appNotification';
|
||||
import { contextSrv } from '../../../core/services/context_srv';
|
||||
import { handleError } from '../../utils';
|
||||
import { notifyApp } from '../../../../core/actions';
|
||||
import { createSuccessNotification } from '../../../../core/copy/appNotification';
|
||||
import { contextSrv } from '../../../../core/services/context_srv';
|
||||
import { handleError } from '../../../utils';
|
||||
|
||||
import { generatedAPI, Playlist, PlaylistSpec } from './endpoints.gen';
|
||||
|
||||
export const playlistAPI = generatedAPI.enhanceEndpoints({
|
||||
export const playlistAPIv0alpha1 = generatedAPI.enhanceEndpoints({
|
||||
endpoints: {
|
||||
getPlaylist: {
|
||||
transformResponse: async (response: Playlist) => {
|
||||
@@ -81,7 +81,7 @@ export const {
|
||||
useGetPlaylistQuery,
|
||||
useListPlaylistQuery,
|
||||
useReplacePlaylistMutation,
|
||||
} = playlistAPI;
|
||||
} = playlistAPIv0alpha1;
|
||||
|
||||
// eslint-disable-next-line no-barrel-files/no-barrel-files
|
||||
export type { Playlist } from './endpoints.gen';
|
||||
@@ -1,6 +1,6 @@
|
||||
import { parseListOptionsSelector } from '../../../../features/apiserver/client';
|
||||
import { ListOptions } from '../../../../features/apiserver/types';
|
||||
import { ListRepositoryApiArg } from '../endpoints.gen';
|
||||
import { ListRepositoryApiArg } from '../v0alpha1/endpoints.gen';
|
||||
|
||||
type ListParams = Omit<ListRepositoryApiArg, 'fieldSelector' | 'labelSelector'> &
|
||||
Pick<ListOptions, 'labelSelector' | 'fieldSelector'>;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import { createBaseQuery } from 'app/api/createBaseQuery';
|
||||
export const BASE_URL = `apis/provisioning.grafana.app/v0alpha1/namespaces/${config.namespace}`;
|
||||
|
||||
export const api = createApi({
|
||||
reducerPath: 'provisioningAPI',
|
||||
reducerPath: 'provisioningAPIv0alpha1',
|
||||
baseQuery: createBaseQuery({
|
||||
baseURL: BASE_URL,
|
||||
}),
|
||||
+5
-4
@@ -1,12 +1,13 @@
|
||||
import { t } from '@grafana/i18n';
|
||||
import { isFetchError } from '@grafana/runtime';
|
||||
import { notifyApp } from 'app/core/actions';
|
||||
import { createSuccessNotification, createErrorNotification } from 'app/core/copy/appNotification';
|
||||
|
||||
import { notifyApp } from '../../../../core/actions';
|
||||
import { createSuccessNotification, createErrorNotification } from '../../../../core/copy/appNotification';
|
||||
import { createOnCacheEntryAdded } from '../utils/createOnCacheEntryAdded';
|
||||
|
||||
import { generatedAPI, JobSpec, JobStatus, RepositorySpec, RepositoryStatus, ErrorDetails } from './endpoints.gen';
|
||||
import { createOnCacheEntryAdded } from './utils/createOnCacheEntryAdded';
|
||||
|
||||
export const provisioningAPI = generatedAPI.enhanceEndpoints({
|
||||
export const provisioningAPIv0alpha1 = generatedAPI.enhanceEndpoints({
|
||||
endpoints: {
|
||||
listJob: {
|
||||
// Do not include 'watch' in the first query, so we can get the initial list of jobs
|
||||
@@ -26,11 +26,11 @@ import teamsReducers from 'app/features/teams/state/reducers';
|
||||
import usersReducers from 'app/features/users/state/reducers';
|
||||
import templatingReducers from 'app/features/variables/state/keyedVariablesReducer';
|
||||
|
||||
import { advisorAPI } from '../../api/clients/advisor';
|
||||
import { folderAPI } from '../../api/clients/folder';
|
||||
import { iamAPI } from '../../api/clients/iam';
|
||||
import { playlistAPI } from '../../api/clients/playlist';
|
||||
import { provisioningAPI } from '../../api/clients/provisioning';
|
||||
import { advisorAPIv0alpha1 } from '../../api/clients/advisor/v0alpha1';
|
||||
import { folderAPIv1beta1 } from '../../api/clients/folder/v1beta1';
|
||||
import { iamAPIv0alpha1 } from '../../api/clients/iam/v0alpha1';
|
||||
import { playlistAPIv0alpha1 } from '../../api/clients/playlist/v0alpha1';
|
||||
import { provisioningAPIv0alpha1 } from '../../api/clients/provisioning/v0alpha1';
|
||||
import { alertingApi } from '../../features/alerting/unified/api/alertingApi';
|
||||
import { userPreferencesAPI } from '../../features/preferences/api';
|
||||
import { cleanUpAction } from '../actions/cleanUp';
|
||||
@@ -63,12 +63,12 @@ const rootReducers = {
|
||||
[publicDashboardApi.reducerPath]: publicDashboardApi.reducer,
|
||||
[browseDashboardsAPI.reducerPath]: browseDashboardsAPI.reducer,
|
||||
[cloudMigrationAPI.reducerPath]: cloudMigrationAPI.reducer,
|
||||
[iamAPI.reducerPath]: iamAPI.reducer,
|
||||
[playlistAPI.reducerPath]: playlistAPI.reducer,
|
||||
[iamAPIv0alpha1.reducerPath]: iamAPIv0alpha1.reducer,
|
||||
[playlistAPIv0alpha1.reducerPath]: playlistAPIv0alpha1.reducer,
|
||||
[userPreferencesAPI.reducerPath]: userPreferencesAPI.reducer,
|
||||
[provisioningAPI.reducerPath]: provisioningAPI.reducer,
|
||||
[folderAPI.reducerPath]: folderAPI.reducer,
|
||||
[advisorAPI.reducerPath]: advisorAPI.reducer,
|
||||
[provisioningAPIv0alpha1.reducerPath]: provisioningAPIv0alpha1.reducer,
|
||||
[folderAPIv1beta1.reducerPath]: folderAPIv1beta1.reducer,
|
||||
[advisorAPIv0alpha1.reducerPath]: advisorAPIv0alpha1.reducer,
|
||||
// PLOP_INJECT_REDUCER
|
||||
// Used by the API client generator
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ import { t } from '@grafana/i18n';
|
||||
import { config, getBackendSrv, locationService } from '@grafana/runtime';
|
||||
import { Dashboard } from '@grafana/schema';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { folderAPI } from 'app/api/clients/folder';
|
||||
import { folderAPIv1beta1 as folderAPI } from 'app/api/clients/folder/v1beta1';
|
||||
import { createBaseQuery, handleRequestError } from 'app/api/createBaseQuery';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Folder } from 'app/api/clients/folder';
|
||||
import { Folder } from 'app/api/clients/folder/v1beta1';
|
||||
import { AnnoKeyManagerKind, ManagerKind } from 'app/features/apiserver/types';
|
||||
import { DashboardDTO } from 'app/types';
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import userEvent from '@testing-library/user-event';
|
||||
|
||||
import { AppEvents } from '@grafana/data';
|
||||
import { getAppEvents } from '@grafana/runtime';
|
||||
import { useGetFolderQuery } from 'app/api/clients/folder';
|
||||
import { useCreateRepositoryFilesWithPathMutation } from 'app/api/clients/provisioning';
|
||||
import { useGetFolderQuery } from 'app/api/clients/folder/v1beta1';
|
||||
import { useCreateRepositoryFilesWithPathMutation } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { validationSrv } from 'app/features/manage-dashboards/services/ValidationSrv';
|
||||
import { useGetResourceRepositoryView } from 'app/features/provisioning/hooks/useGetResourceRepositoryView';
|
||||
import { usePullRequestParam } from 'app/features/provisioning/hooks/usePullRequestParam';
|
||||
@@ -35,13 +35,13 @@ jest.mock('app/features/manage-dashboards/services/ValidationSrv', () => {
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('app/api/clients/provisioning', () => {
|
||||
jest.mock('app/api/clients/provisioning/v0alpha1', () => {
|
||||
return {
|
||||
useCreateRepositoryFilesWithPathMutation: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('app/api/clients/folder', () => {
|
||||
jest.mock('app/api/clients/folder/v1beta1', () => {
|
||||
return {
|
||||
useGetFolderQuery: jest.fn(),
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ import { AppEvents } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { getAppEvents } from '@grafana/runtime';
|
||||
import { Alert, Button, Field, Input, RadioButtonGroup, Spinner, Stack, TextArea } from '@grafana/ui';
|
||||
import { useCreateRepositoryFilesWithPathMutation } from 'app/api/clients/provisioning';
|
||||
import { useCreateRepositoryFilesWithPathMutation } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { AnnoKeySourcePath, Resource } from 'app/features/apiserver/types';
|
||||
import { getDefaultWorkflow, getWorkflowOptions } from 'app/features/dashboard-scene/saving/provisioned/defaults';
|
||||
import { validationSrv } from 'app/features/manage-dashboards/services/ValidationSrv';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { t } from '@grafana/i18n';
|
||||
import { config, getBackendSrv, isFetchError, locationService } from '@grafana/runtime';
|
||||
import { sceneGraph } from '@grafana/scenes';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { BASE_URL } from 'app/api/clients/provisioning/baseAPI';
|
||||
import { BASE_URL } from 'app/api/clients/provisioning/v0alpha1/baseAPI';
|
||||
import { StateManagerBase } from 'app/core/services/StateManagerBase';
|
||||
import { getMessageFromError, getMessageIdFromError, getStatusFromError } from 'app/core/utils/errors';
|
||||
import { startMeasure, stopMeasure } from 'app/core/utils/metrics';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { textUtil } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { Alert, Icon, Stack } from '@grafana/ui';
|
||||
import { useGetRepositoryFilesWithPathQuery } from 'app/api/clients/provisioning';
|
||||
import { useGetRepositoryFilesWithPathQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { DashboardPageRouteSearchParams } from 'app/features/dashboard/containers/types';
|
||||
import { usePullRequestParam } from 'app/features/provisioning/hooks/usePullRequestParam';
|
||||
import { DashboardRoutes } from 'app/types';
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import { Trans, t } from '@grafana/i18n';
|
||||
import { getAppEvents, locationService } from '@grafana/runtime';
|
||||
import { Dashboard } from '@grafana/schema';
|
||||
import { Alert, Button, Field, Input, RadioButtonGroup, Stack, TextArea } from '@grafana/ui';
|
||||
import { RepositoryView } from 'app/api/clients/provisioning';
|
||||
import { RepositoryView } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||
import kbn from 'app/core/utils/kbn';
|
||||
import { Resource } from 'app/features/apiserver/types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { t } from '@grafana/i18n';
|
||||
import { RepositoryView } from 'app/api/clients/provisioning';
|
||||
import { RepositoryView } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
export function getDefaultWorkflow(config?: RepositoryView, loadedFromRef?: string) {
|
||||
if (loadedFromRef && loadedFromRef !== config?.branch) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { config } from '@grafana/runtime';
|
||||
import { folderAPI } from 'app/api/clients/folder';
|
||||
import { folderAPIv1beta1 as folderAPI } from 'app/api/clients/folder/v1beta1';
|
||||
import { AnnoKeyManagerIdentity, AnnoKeyManagerKind, ManagerKind } from 'app/features/apiserver/types';
|
||||
import { dispatch } from 'app/store/store';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { attachSkeleton, SkeletonComponent } from '@grafana/ui/unstable';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import { DashNavButton } from 'app/features/dashboard/components/DashNav/DashNavButton';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { ShareModal } from './ShareModal';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Trans, t } from '@grafana/i18n';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
|
||||
import { Playlist, useGetPlaylistQuery, useReplacePlaylistMutation } from '../../api/clients/playlist';
|
||||
import { Playlist, useGetPlaylistQuery, useReplacePlaylistMutation } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { PlaylistForm } from './PlaylistForm';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { render, screen, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { PlaylistForm } from './PlaylistForm';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Form } from 'app/core/components/Form/Form';
|
||||
import { DashboardPicker } from 'app/core/components/Select/DashboardPicker';
|
||||
import { TagFilter } from 'app/core/components/TagFilter/TagFilter';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
import { getGrafanaSearcher } from '../search/service/searcher';
|
||||
|
||||
import { PlaylistTable } from './PlaylistTable';
|
||||
|
||||
@@ -5,7 +5,7 @@ import { t } from '@grafana/i18n';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
|
||||
import { Playlist, useCreatePlaylistMutation } from '../../api/clients/playlist';
|
||||
import { Playlist, useCreatePlaylistMutation } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { PlaylistForm } from './PlaylistForm';
|
||||
import { getDefaultPlaylist } from './utils';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Page } from 'app/core/components/Page/Page';
|
||||
import PageActionBar from 'app/core/components/PageActionBar/PageActionBar';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
|
||||
import { Playlist, useDeletePlaylistMutation, useListPlaylistQuery } from '../../api/clients/playlist';
|
||||
import { Playlist, useDeletePlaylistMutation, useListPlaylistQuery } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { PlaylistPageList } from './PlaylistPageList';
|
||||
import { StartModal } from './StartModal';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { useStyles2 } from '@grafana/ui';
|
||||
import { SkeletonComponent, attachSkeleton } from '@grafana/ui/unstable';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { PlaylistCard } from './PlaylistCard';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import configureMockStore from 'redux-mock-store';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { setStore } from 'app/store/store';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
import { DashboardQueryResult } from '../search/service/types';
|
||||
|
||||
import { PlaylistSrv } from './PlaylistSrv';
|
||||
|
||||
@@ -5,7 +5,7 @@ import { locationUtil, urlUtil, rangeUtil } from '@grafana/data';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { StateManagerBase } from 'app/core/services/StateManagerBase';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { loadDashboards } from './utils';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useParams } from 'react-router-dom-v5-compat';
|
||||
|
||||
import { useGetPlaylistQuery } from '../../api/clients/playlist';
|
||||
import { useGetPlaylistQuery } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { playlistSrv } from './PlaylistSrv';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Trans, t } from '@grafana/i18n';
|
||||
import { config, locationService, reportInteraction } from '@grafana/runtime';
|
||||
import { Box, Button, Checkbox, Field, FieldSet, Modal, RadioButtonGroup, Stack } from '@grafana/ui';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
|
||||
import { PlaylistMode } from './types';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
import { DashboardQueryResult } from '../search/service/types';
|
||||
export type PlaylistMode = boolean;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { config } from '@grafana/runtime';
|
||||
import { getGrafanaDatasource } from 'app/plugins/datasource/grafana/datasource';
|
||||
import { GrafanaQuery, GrafanaQueryType } from 'app/plugins/datasource/grafana/types';
|
||||
|
||||
import { Playlist } from '../../api/clients/playlist';
|
||||
import { Playlist } from '../../api/clients/playlist/v0alpha1';
|
||||
import { getGrafanaSearcher } from '../search/service/searcher';
|
||||
import { DashboardQueryResult, SearchQuery } from '../search/service/types';
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Stack,
|
||||
Switch,
|
||||
} from '@grafana/ui';
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { FormPrompt } from 'app/core/components/FormPrompt/FormPrompt';
|
||||
|
||||
import { TokenPermissionsInfo } from '../Shared/TokenPermissionsInfo';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { t } from '@grafana/i18n';
|
||||
|
||||
import { RepositorySpec } from '../../../api/clients/provisioning';
|
||||
import { RepositorySpec } from '../../../api/clients/provisioning/v0alpha1';
|
||||
import { RepositoryFormData } from '../types';
|
||||
import { specToData } from '../utils/data';
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ import { useParams } from 'react-router-dom-v5-compat';
|
||||
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Card, EmptyState, Spinner, Stack, Text, TextLink, UserIcon } from '@grafana/ui';
|
||||
import { useGetRepositoryHistoryWithPathQuery, useGetRepositoryStatusQuery } from 'app/api/clients/provisioning';
|
||||
import {
|
||||
useGetRepositoryHistoryWithPathQuery,
|
||||
useGetRepositoryStatusQuery,
|
||||
} from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { isNotFoundError } from 'app/features/alerting/unified/api/util';
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
ResourceWrapper,
|
||||
useReplaceRepositoryFilesWithPathMutation,
|
||||
useDeleteRepositoryFilesWithPathMutation,
|
||||
} from 'app/api/clients/provisioning';
|
||||
} from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from 'react';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { CellProps, Column, FilterInput, InteractiveTable, LinkButton, Spinner, Stack } from '@grafana/ui';
|
||||
import { Repository, useGetRepositoryFilesQuery } from 'app/api/clients/provisioning';
|
||||
import { Repository, useGetRepositoryFilesQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
import { FileDetails } from '../types';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { css } from '@emotion/css';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Stack, Text, Box, LinkButton, useStyles2 } from '@grafana/ui';
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { ConnectRepositoryButton } from '../Shared/ConnectRepositoryButton';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState } from 'react';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, Stack, useStyles2 } from '@grafana/ui';
|
||||
import { useGetFrontendSettingsQuery, Repository } from 'app/api/clients/provisioning';
|
||||
import { useGetFrontendSettingsQuery, Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import provisioningSvg from 'img/provisioning/provisioning.svg';
|
||||
|
||||
import { EnhancedFeatures } from './EnhancedFeatures';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Box, Text, TextLink } from '@grafana/ui';
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
|
||||
import GettingStarted from './GettingStarted';
|
||||
|
||||
@@ -2,7 +2,10 @@ import { useMemo, useState } from 'react';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, ConfirmModal, Stack, Tab, TabContent, TabsBar } from '@grafana/ui';
|
||||
import { useDeletecollectionRepositoryMutation, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning';
|
||||
import {
|
||||
useDeletecollectionRepositoryMutation,
|
||||
useGetFrontendSettingsQuery,
|
||||
} from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
|
||||
import GettingStarted from './GettingStarted/GettingStarted';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useRef } from 'react';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, Spinner, Stack, Text } from '@grafana/ui';
|
||||
import { useGetRepositoryJobsWithPathQuery } from 'app/api/clients/provisioning';
|
||||
import { useGetRepositoryJobsWithPathQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { useStepStatus } from '../Wizard/StepStatusContext';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, ControlledCollapse, Spinner, Stack, Text } from '@grafana/ui';
|
||||
import { Job } from 'app/api/clients/provisioning';
|
||||
import { Job } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { RepositoryLink } from '../Repository/RepositoryLink';
|
||||
import ProgressBar from '../Shared/ProgressBar';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Spinner, Stack, Text } from '@grafana/ui';
|
||||
import { Job, useListJobQuery } from 'app/api/clients/provisioning';
|
||||
import { Job, useListJobQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { useStepStatus } from '../Wizard/StepStatusContext';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { InteractiveTable, Stack } from '@grafana/ui';
|
||||
import { JobResourceSummary } from 'app/api/clients/provisioning';
|
||||
import { JobResourceSummary } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
type SummaryCell<T extends keyof JobResourceSummary = keyof JobResourceSummary> = {
|
||||
row: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
||||
import { intervalToAbbreviatedDurationString, TraceKeyValuePair } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, Badge, Box, Card, Icon, InteractiveTable, Spinner, Stack, Text } from '@grafana/ui';
|
||||
import { Job, Repository, SyncStatus } from 'app/api/clients/provisioning';
|
||||
import { Job, Repository, SyncStatus } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import KeyValuesTable from 'app/features/explore/TraceView/components/TraceTimelineViewer/SpanDetail/KeyValuesTable';
|
||||
|
||||
import { useRepositoryAllJobs } from '../hooks/useRepositoryAllJobs';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Button, Spinner } from '@grafana/ui';
|
||||
import { Repository, useCreateRepositoryTestMutation } from 'app/api/clients/provisioning';
|
||||
import { Repository, useCreateRepositoryTestMutation } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
interface Props {
|
||||
repository: Repository;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom-v5-compat';
|
||||
|
||||
import { t } from '@grafana/i18n';
|
||||
import { ConfirmModal, IconButton } from '@grafana/ui';
|
||||
import { useDeleteRepositoryMutation } from 'app/api/clients/provisioning';
|
||||
import { useDeleteRepositoryMutation } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
interface Props {
|
||||
name: string;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useParams } from 'react-router-dom-v5-compat';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { EmptyState, Text, TextLink } from '@grafana/ui';
|
||||
import { useGetRepositoryQuery } from 'app/api/clients/provisioning';
|
||||
import { useGetRepositoryQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
|
||||
import { ConfigForm } from '../Config/ConfigForm';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Button, LinkButton, Stack } from '@grafana/ui';
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { StatusBadge } from '../Shared/StatusBadge';
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
||||
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { IconName, Stack, Text, TextLink, Icon, Card, LinkButton } from '@grafana/ui';
|
||||
import { Repository, ResourceCount } from 'app/api/clients/provisioning';
|
||||
import { Repository, ResourceCount } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { StatusBadge } from '../Shared/StatusBadge';
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Stack, Alert, Text } from '@grafana/ui';
|
||||
import { HealthStatus } from 'app/api/clients/provisioning';
|
||||
import { HealthStatus } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
interface Props {
|
||||
health: HealthStatus;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { skipToken } from '@reduxjs/toolkit/query';
|
||||
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Stack, Text, TextLink } from '@grafana/ui';
|
||||
import { useGetRepositoryQuery } from 'app/api/clients/provisioning';
|
||||
import { useGetRepositoryQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { getRepoHref } from '../utils/git';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Box, Card, CellProps, Grid, InteractiveTable, LinkButton, Stack, Text, useStyles2 } from '@grafana/ui';
|
||||
import { Repository, ResourceCount } from 'app/api/clients/provisioning';
|
||||
import { Repository, ResourceCount } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { RecentJobs } from '../Job/RecentJobs';
|
||||
import { formatTimestamp } from '../utils/time';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { CellProps, Column, FilterInput, InteractiveTable, Link, LinkButton, Spinner, Stack } from '@grafana/ui';
|
||||
import { Repository, ResourceListItem, useGetRepositoryResourcesQuery } from 'app/api/clients/provisioning';
|
||||
import { Repository, ResourceListItem, useGetRepositoryResourcesQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useParams } from 'react-router-dom-v5-compat';
|
||||
import { SelectableValue, urlUtil } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, EmptyState, Spinner, Tab, TabContent, TabsBar, Text, TextLink } from '@grafana/ui';
|
||||
import { useGetFrontendSettingsQuery, useListRepositoryQuery } from 'app/api/clients/provisioning';
|
||||
import { useGetFrontendSettingsQuery, useListRepositoryQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
||||
import { isNotFoundError } from 'app/features/alerting/unified/api/util';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom-v5-compat';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Button, ConfirmModal } from '@grafana/ui';
|
||||
import { Repository, useCreateRepositoryJobsMutation } from 'app/api/clients/provisioning';
|
||||
import { Repository, useCreateRepositoryJobsMutation } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useNavigate } from 'react-router-dom-v5-compat';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, Button, Dropdown, Icon, LinkButton, Menu, Stack } from '@grafana/ui';
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { RepoType } from '../Wizard/types';
|
||||
import { CONNECT_URL } from '../constants';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from 'react';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { EmptySearchResult, FilterInput, Stack } from '@grafana/ui';
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { RepositoryCard } from '../Repository/RepositoryCard';
|
||||
import { checkSyncSettings } from '../utils/checkSyncSettings';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { Badge, BadgeColor, IconName } from '@grafana/ui';
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ import userEvent from '@testing-library/user-event';
|
||||
import { ReactNode } from 'react';
|
||||
import { useForm, FormProvider } from 'react-hook-form';
|
||||
|
||||
import { useGetRepositoryFilesQuery, useGetResourceStatsQuery } from 'app/api/clients/provisioning';
|
||||
import { useGetRepositoryFilesQuery, useGetResourceStatsQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { BootstrapStep, Props } from './BootstrapStep';
|
||||
import { StepStatusProvider } from './StepStatusContext';
|
||||
import { getResourceStats, useModeOptions } from './actions';
|
||||
import { WizardFormData } from './types';
|
||||
|
||||
jest.mock('app/api/clients/provisioning', () => ({
|
||||
jest.mock('app/api/clients/provisioning/v0alpha1', () => ({
|
||||
useGetRepositoryFilesQuery: jest.fn(),
|
||||
useGetResourceStatsQuery: jest.fn(),
|
||||
}));
|
||||
|
||||
@@ -3,7 +3,11 @@ import { Controller, useFormContext } from 'react-hook-form';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Box, Card, Field, Input, LoadingPlaceholder, Stack, Text } from '@grafana/ui';
|
||||
import { RepositoryViewList, useGetRepositoryFilesQuery, useGetResourceStatsQuery } from 'app/api/clients/provisioning';
|
||||
import {
|
||||
RepositoryViewList,
|
||||
useGetRepositoryFilesQuery,
|
||||
useGetResourceStatsQuery,
|
||||
} from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { useStepStatus } from './StepStatusContext';
|
||||
import { getResourceStats, useModeOptions } from './actions';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { AppEvents, GrafanaTheme2 } from '@grafana/data';
|
||||
import { t } from '@grafana/i18n';
|
||||
import { getAppEvents, isFetchError } from '@grafana/runtime';
|
||||
import { Alert, Box, Button, Stack, Text, useStyles2 } from '@grafana/ui';
|
||||
import { useDeleteRepositoryMutation, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning';
|
||||
import { useDeleteRepositoryMutation, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { FormPrompt } from 'app/core/components/FormPrompt/FormPrompt';
|
||||
|
||||
import { getDefaultValues } from '../Config/defaults';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useFormContext } from 'react-hook-form';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Button, Text, Stack, Alert, TextLink, Field, Checkbox } from '@grafana/ui';
|
||||
import { Job, useCreateRepositoryJobsMutation } from 'app/api/clients/provisioning';
|
||||
import { Job, useCreateRepositoryJobsMutation } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { JobStatus } from '../Job/JobStatus';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
GetRepositoryFilesApiResponse,
|
||||
GetResourceStatsApiResponse,
|
||||
RepositoryViewList,
|
||||
} from 'app/api/clients/provisioning';
|
||||
} from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { ModeOption } from './types';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RepositorySpec, SyncOptions } from 'app/api/clients/provisioning';
|
||||
import { RepositorySpec, SyncOptions } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { RepositoryFormData } from '../types';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
useCreateRepositoryMutation,
|
||||
useCreateRepositoryTestMutation,
|
||||
useReplaceRepositoryMutation,
|
||||
} from 'app/api/clients/provisioning';
|
||||
} from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
export function useCreateOrUpdateRepository(name?: string) {
|
||||
const [create, createRequest] = useCreateRepositoryMutation();
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
ReplaceRepositoryFilesWithPathApiArg,
|
||||
useCreateRepositoryFilesWithPathMutation,
|
||||
useReplaceRepositoryFilesWithPathMutation,
|
||||
} from 'app/api/clients/provisioning';
|
||||
} from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
export function useCreateOrUpdateRepositoryFile(name?: string) {
|
||||
const [create, createRequest] = useCreateRepositoryFilesWithPathMutation();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { skipToken } from '@reduxjs/toolkit/query/react';
|
||||
|
||||
import { Folder, useGetFolderQuery } from 'app/api/clients/folder';
|
||||
import { RepositoryView, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning';
|
||||
import { Folder, useGetFolderQuery } from 'app/api/clients/folder/v1beta1';
|
||||
import { RepositoryView, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { AnnoKeyManagerIdentity } from 'app/features/apiserver/types';
|
||||
|
||||
interface GetResourceRepositoryArgs {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { skipToken } from '@reduxjs/toolkit/query';
|
||||
|
||||
import { config } from '@grafana/runtime';
|
||||
import { RepositoryViewList, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning';
|
||||
import { RepositoryViewList, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
export function useIsProvisionedInstance(settings?: RepositoryViewList) {
|
||||
const settingsQuery = useGetFrontendSettingsQuery(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useDebounce } from 'react-use';
|
||||
|
||||
import { Job, useGetRepositoryJobsQuery, useListJobQuery } from 'app/api/clients/provisioning';
|
||||
import { Job, useGetRepositoryJobsQuery, useListJobQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
interface RepositoryHistoricalJobsArgs {
|
||||
/** Limits the returned jobs to those which apply to this repository. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { skipToken } from '@reduxjs/toolkit/query/react';
|
||||
|
||||
import { Job, useListJobQuery } from 'app/api/clients/provisioning';
|
||||
import { Job, useListJobQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
interface RepositoryJobsArgs {
|
||||
name?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { skipToken } from '@reduxjs/toolkit/query';
|
||||
|
||||
import { ListRepositoryApiArg, Repository, useListRepositoryQuery } from 'app/api/clients/provisioning';
|
||||
import { ListRepositoryApiArg, Repository, useListRepositoryQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
// Sort repositories alphabetically by title
|
||||
export function useRepositoryList(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GitHubRepositoryConfig, LocalRepositoryConfig, RepositorySpec } from '../../api/clients/provisioning';
|
||||
import { GitHubRepositoryConfig, LocalRepositoryConfig, RepositorySpec } from '../../api/clients/provisioning/v0alpha1';
|
||||
|
||||
export type RepositoryFormData = Omit<RepositorySpec, 'github' | 'local' | 'workflows'> &
|
||||
GitHubRepositoryConfig &
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Repository } from 'app/api/clients/provisioning';
|
||||
import { Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
type syncState = {
|
||||
instanceConnected: boolean;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RepositorySpec } from 'app/api/clients/provisioning';
|
||||
import { RepositorySpec } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { RepositoryFormData } from '../types';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ErrorDetails } from 'app/api/clients/provisioning';
|
||||
import { ErrorDetails } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
import { WizardFormData } from '../Wizard/types';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RepositorySpec } from 'app/api/clients/provisioning';
|
||||
import { RepositorySpec } from 'app/api/clients/provisioning/v0alpha1';
|
||||
|
||||
/**
|
||||
* Validates a Git branch name according to the following rules:
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
import { RootState } from 'app/store/configureStore';
|
||||
|
||||
import { Repository, provisioningAPI } from '../../../api/clients/provisioning/index';
|
||||
import { Repository, provisioningAPIv0alpha1 as provisioningAPI } from '../../../api/clients/provisioning/v0alpha1';
|
||||
|
||||
const emptyRepos: Repository[] = [];
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ import { cloudMigrationAPI } from 'app/features/migrate-to-cloud/api';
|
||||
import { userPreferencesAPI } from 'app/features/preferences/api';
|
||||
import { StoreState } from 'app/types/store';
|
||||
|
||||
import { advisorAPI } from '../api/clients/advisor';
|
||||
import { folderAPI } from '../api/clients/folder';
|
||||
import { iamAPI } from '../api/clients/iam';
|
||||
import { playlistAPI } from '../api/clients/playlist';
|
||||
import { provisioningAPI } from '../api/clients/provisioning';
|
||||
import { advisorAPIv0alpha1 } from '../api/clients/advisor/v0alpha1';
|
||||
import { folderAPIv1beta1 } from '../api/clients/folder/v1beta1';
|
||||
import { iamAPIv0alpha1 } from '../api/clients/iam/v0alpha1';
|
||||
import { playlistAPIv0alpha1 } from '../api/clients/playlist/v0alpha1';
|
||||
import { provisioningAPIv0alpha1 } from '../api/clients/provisioning/v0alpha1';
|
||||
// Used by the API client generator
|
||||
// PLOP_INJECT_IMPORT
|
||||
import { buildInitialState } from '../core/reducers/navModel';
|
||||
@@ -46,11 +46,11 @@ export function configureStore(initialState?: Partial<StoreState>) {
|
||||
browseDashboardsAPI.middleware,
|
||||
cloudMigrationAPI.middleware,
|
||||
userPreferencesAPI.middleware,
|
||||
iamAPI.middleware,
|
||||
playlistAPI.middleware,
|
||||
provisioningAPI.middleware,
|
||||
folderAPI.middleware,
|
||||
advisorAPI.middleware,
|
||||
iamAPIv0alpha1.middleware,
|
||||
playlistAPIv0alpha1.middleware,
|
||||
provisioningAPIv0alpha1.middleware,
|
||||
folderAPIv1beta1.middleware,
|
||||
advisorAPIv0alpha1.middleware,
|
||||
// PLOP_INJECT_MIDDLEWARE
|
||||
// Used by the API client generator
|
||||
...extraMiddleware
|
||||
|
||||
@@ -41,27 +41,27 @@ const config: ConfigFile = {
|
||||
apiImport: 'baseAPI',
|
||||
filterEndpoints: ['getUserPreferences', 'updateUserPreferences', 'patchUserPreferences'],
|
||||
},
|
||||
'../public/app/api/clients/iam/endpoints.gen.ts': {
|
||||
'../public/app/api/clients/iam/v0alpha1/endpoints.gen.ts': {
|
||||
schemaFile: '../data/openapi/iam.grafana.app-v0alpha1.json',
|
||||
apiFile: '../public/app/api/clients/iam/baseAPI.ts',
|
||||
apiFile: '../public/app/api/clients/iam/v0alpha1/baseAPI.ts',
|
||||
filterEndpoints: ['getDisplayMapping'],
|
||||
tag: true,
|
||||
},
|
||||
'../public/app/api/clients/provisioning/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/provisioning/baseAPI.ts',
|
||||
'../public/app/api/clients/provisioning/v0alpha1/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/provisioning/v0alpha1/baseAPI.ts',
|
||||
schemaFile: '../data/openapi/provisioning.grafana.app-v0alpha1.json',
|
||||
filterEndpoints,
|
||||
tag: true,
|
||||
hooks: true,
|
||||
},
|
||||
'../public/app/api/clients/folder/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/folder/baseAPI.ts',
|
||||
'../public/app/api/clients/folder/v1beta1/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/folder/v1beta1/baseAPI.ts',
|
||||
schemaFile: '../data/openapi/folder.grafana.app-v1beta1.json',
|
||||
filterEndpoints: ['getFolder'],
|
||||
tag: true,
|
||||
},
|
||||
'../public/app/api/clients/advisor/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/advisor/baseAPI.ts',
|
||||
'../public/app/api/clients/advisor/v0alpha1/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/advisor/v0alpha1/baseAPI.ts',
|
||||
schemaFile: '../data/openapi/advisor.grafana.app-v0alpha1.json',
|
||||
filterEndpoints: [
|
||||
'createCheck',
|
||||
@@ -74,8 +74,8 @@ const config: ConfigFile = {
|
||||
],
|
||||
tag: true,
|
||||
},
|
||||
'../public/app/api/clients/playlist/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/playlist/baseAPI.ts',
|
||||
'../public/app/api/clients/playlist/v0alpha1/endpoints.gen.ts': {
|
||||
apiFile: '../public/app/api/clients/playlist/v0alpha1/baseAPI.ts',
|
||||
schemaFile: '../data/openapi/playlist.grafana.app-v0alpha1.json',
|
||||
filterEndpoints: ['listPlaylist', 'getPlaylist', 'createPlaylist', 'deletePlaylist', 'replacePlaylist'],
|
||||
tag: true,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# RTK Query API Client Generator
|
||||
|
||||
This generator automates the process of creating RTK Query API clients for Grafana's API groups. It replaces the manual steps outlined in the [main API documentation](../README.md).
|
||||
This generator automates the process of creating RTK Query API clients for Grafana's API groups. It replaces the manual steps outlined in the [main API documentation](../../public/app/api/README.md).
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -42,7 +42,7 @@ The generator automates the following:
|
||||
If an error about a missing OpenAPI schema appears, check that:
|
||||
|
||||
1. The API group and version exist in the backend
|
||||
2. The `TestIntegrationOpenAPIs` test has been run to generate the schema (step 1 in the [main API documentation](../README.md)).
|
||||
2. The `TestIntegrationOpenAPIs` test has been run to generate the schema (step 1 in the [main API documentation](../../public/app/api/README.md)).
|
||||
3. The schema file exists at `data/openapi/<group>-<version>.json`
|
||||
|
||||
### Validation Errors
|
||||
|
||||
@@ -33,13 +33,13 @@ export const formatEndpoints = () => (endpointsInput: string | string[]) => {
|
||||
};
|
||||
|
||||
// List of created or modified files
|
||||
export const getFilesToFormat = (groupName: string, isEnterprise = false) => {
|
||||
export const getFilesToFormat = (groupName: string, version: string, isEnterprise = false) => {
|
||||
const apiClientBasePath = isEnterprise ? 'public/app/extensions/api/clients' : 'public/app/api/clients';
|
||||
const generateScriptPath = isEnterprise ? 'local/generate-enterprise-apis.ts' : 'scripts/generate-rtk-apis.ts';
|
||||
|
||||
return [
|
||||
`${apiClientBasePath}/${groupName}/baseAPI.ts`,
|
||||
`${apiClientBasePath}/${groupName}/index.ts`,
|
||||
`${apiClientBasePath}/${groupName}/${version}/baseAPI.ts`,
|
||||
`${apiClientBasePath}/${groupName}/${version}/index.ts`,
|
||||
generateScriptPath,
|
||||
...(isEnterprise ? [] : [`public/app/core/reducers/root.ts`, `public/app/store/configureStore.ts`]),
|
||||
];
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function plopGenerator(plop: NodePlopAPI) {
|
||||
plop.setHelper('formatEndpoints', formatEndpoints());
|
||||
|
||||
const generateRtkApiActions = (data: PlopData) => {
|
||||
const { reducerPath, groupName, isEnterprise } = data;
|
||||
const { reducerPath, groupName, version, isEnterprise } = data;
|
||||
|
||||
const apiClientBasePath = isEnterprise ? 'public/app/extensions/api/clients' : 'public/app/api/clients';
|
||||
const generateScriptPath = isEnterprise ? 'local/generate-enterprise-apis.ts' : 'scripts/generate-rtk-apis.ts';
|
||||
@@ -46,7 +46,7 @@ export default function plopGenerator(plop: NodePlopAPI) {
|
||||
const actions: ActionConfig[] = [
|
||||
{
|
||||
type: 'add',
|
||||
path: path.join(basePath, `${apiClientBasePath}/${groupName}/baseAPI.ts`),
|
||||
path: path.join(basePath, `${apiClientBasePath}/${groupName}/${version}/baseAPI.ts`),
|
||||
templateFile: './templates/baseAPI.ts.hbs',
|
||||
},
|
||||
{
|
||||
@@ -58,7 +58,7 @@ export default function plopGenerator(plop: NodePlopAPI) {
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: path.join(basePath, `${apiClientBasePath}/${groupName}/index.ts`),
|
||||
path: path.join(basePath, `${apiClientBasePath}/${groupName}/${version}/index.ts`),
|
||||
templateFile: './templates/index.ts.hbs',
|
||||
},
|
||||
];
|
||||
@@ -70,7 +70,7 @@ export default function plopGenerator(plop: NodePlopAPI) {
|
||||
type: 'modify',
|
||||
path: path.join(basePath, 'public/app/core/reducers/root.ts'),
|
||||
pattern: '// PLOP_INJECT_IMPORT',
|
||||
template: `import { ${reducerPath} } from '${clientImportPath}/${groupName}';\n// PLOP_INJECT_IMPORT`,
|
||||
template: `import { ${reducerPath} } from '${clientImportPath}/${groupName}/${version}';\n// PLOP_INJECT_IMPORT`,
|
||||
},
|
||||
{
|
||||
type: 'modify',
|
||||
@@ -82,7 +82,7 @@ export default function plopGenerator(plop: NodePlopAPI) {
|
||||
type: 'modify',
|
||||
path: path.join(basePath, 'public/app/store/configureStore.ts'),
|
||||
pattern: '// PLOP_INJECT_IMPORT',
|
||||
template: `import { ${reducerPath} } from '${clientImportPath}/${groupName}';\n// PLOP_INJECT_IMPORT`,
|
||||
template: `import { ${reducerPath} } from '${clientImportPath}/${groupName}/${version}';\n// PLOP_INJECT_IMPORT`,
|
||||
},
|
||||
{
|
||||
type: 'modify',
|
||||
@@ -97,7 +97,7 @@ export default function plopGenerator(plop: NodePlopAPI) {
|
||||
actions.push(
|
||||
{
|
||||
type: 'formatFiles',
|
||||
files: getFilesToFormat(groupName, isEnterprise),
|
||||
files: getFilesToFormat(groupName, version, isEnterprise),
|
||||
},
|
||||
{
|
||||
type: 'runGenerateApis',
|
||||
@@ -140,10 +140,12 @@ export default function plopGenerator(plop: NodePlopAPI) {
|
||||
{
|
||||
type: 'input',
|
||||
name: 'reducerPath',
|
||||
message: 'Reducer path (e.g. dashboardAPI):',
|
||||
default: (answers: { groupName?: string }) => `${answers.groupName}API`,
|
||||
message: 'Reducer path (e.g. dashboardAPIv0alpha1):',
|
||||
default: (answers: { groupName?: string; version?: string }) => `${answers.groupName}API${answers.version}`,
|
||||
validate: (input: string) =>
|
||||
input?.endsWith('API') ? true : 'Reducer path should end with "API" (e.g. dashboardAPI)',
|
||||
input?.endsWith('API') || input?.match(/API[a-z]\d+[a-z]*\d*$/)
|
||||
? true
|
||||
: 'Reducer path should end with "API" or "API<version>" (e.g. dashboardAPI, dashboardAPIv0alpha1)',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'{{apiPathPrefix}}/{{groupName}}/endpoints.gen.ts': {
|
||||
apiFile: '{{apiPathPrefix}}/{{groupName}}/baseAPI.ts',
|
||||
'{{apiPathPrefix}}/{{groupName}}/{{version}}/endpoints.gen.ts': {
|
||||
apiFile: '{{apiPathPrefix}}/{{groupName}}/{{version}}/baseAPI.ts',
|
||||
schemaFile: '../data/openapi/{{group}}-{{version}}.json',
|
||||
{{#if endpoints}}
|
||||
filterEndpoints: [{{{formatEndpoints endpoints}}}],
|
||||
|
||||
Reference in New Issue
Block a user