Skip to content

Commit

Permalink
Minor: add Content-type for patch request in request interceptor (#14879
Browse files Browse the repository at this point in the history
)

* Minor: add Content-Type for patch request in request interceptor

* Fix importGlossaryInCSVFormat content-type header
  • Loading branch information
Sachin-chaurasiya authored Jan 26, 2024
1 parent 6c4e7a4 commit c7e6619
Show file tree
Hide file tree
Showing 31 changed files with 133 additions and 281 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ export const AuthProvider = ({
}
}

if (config.method === 'patch' && config.headers) {
config.headers['Content-type'] = 'application/json-patch+json';
}

return withDomainFilter(config);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,6 @@ export const getKpiPath = (kpiName: string) => {
return path;
};

export const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

export const NOTIFICATION_READ_TIMER = 2500;
export const TIER_CATEGORY = 'Tier';

Expand Down Expand Up @@ -843,3 +839,7 @@ export const ICON_DIMENSION = {
export const COMMON_ICON_STYLES: CSSProperties = {
verticalAlign: 'middle',
};

export const APPLICATION_JSON_CONTENT_TYPE_HEADER = {
headers: { 'Content-type': 'application/json' },
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ export const createDocument = async (data: CreateDocument) => {
};

export const updateDocument = async (id: string, data: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};
const response = await axiosClient.patch<
Operation[],
AxiosResponse<Document>
>(`${BASE_URL}/${id}`, data, configOptions);
>(`${BASE_URL}/${id}`, data);

return response.data;
};
7 changes: 1 addition & 6 deletions openmetadata-ui/src/main/resources/ui/src/rest/KpiAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,9 @@ export const putKPI = async (data: CreateKpiRequest) => {
};

export const patchKPI = async (id: string, data: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<Operation[], AxiosResponse<Kpi>>(
`/kpi/${id}`,
data,
configOptions
data
);

return response.data;
Expand Down
6 changes: 1 addition & 5 deletions openmetadata-ui/src/main/resources/ui/src/rest/PersonaAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,9 @@ export const createPersona = async (data: CreatePersona) => {
};

export const updatePersona = async (id: string, data: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};
const response = await axiosClient.patch<Operation[], AxiosResponse<Persona>>(
`${BASE_URL}/${id}`,
data,
configOptions
data
);

return response.data;
Expand Down
26 changes: 11 additions & 15 deletions openmetadata-ui/src/main/resources/ui/src/rest/SearchIndexAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { AxiosResponse } from 'axios';
import { Operation } from 'fast-json-patch';
import { PagingResponse, PagingWithoutTotal, RestoreRequestType } from 'Models';
import { QueryVote } from '../components/TableQueries/TableQueries.interface';
import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants';
import {
EntityReference,
SearchIndex,
Expand Down Expand Up @@ -64,14 +65,10 @@ export const patchSearchIndexDetails = async (
id: string,
data: Operation[]
) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<
Operation[],
AxiosResponse<SearchIndex>
>(`/searchIndexes/${id}`, data, configOptions);
>(`/searchIndexes/${id}`, data);

return response.data;
};
Expand All @@ -86,31 +83,30 @@ export const restoreSearchIndex = async (id: string) => {
};

export const addFollower = async (searchIndexId: string, userId: string) => {
const configOptions = {
headers: { 'Content-type': 'application/json' },
};

const response = await APIClient.put<
string,
AxiosResponse<{
changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] };
}>
>(`/searchIndexes/${searchIndexId}/followers`, userId, configOptions);
>(
`/searchIndexes/${searchIndexId}/followers`,
userId,
APPLICATION_JSON_CONTENT_TYPE_HEADER
);

return response.data;
};

export const removeFollower = async (searchIndexId: string, userId: string) => {
const configOptions = {
headers: { 'Content-type': 'application/json' },
};

const response = await APIClient.delete<
string,
AxiosResponse<{
changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] };
}>
>(`/searchIndexes/${searchIndexId}/followers/${userId}`, configOptions);
>(
`/searchIndexes/${searchIndexId}/followers/${userId}`,
APPLICATION_JSON_CONTENT_TYPE_HEADER
);

return response.data;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,9 @@ export const uninstallApp = (appName: string, hardDelete = false) => {
};

export const patchApplication = async (id: string, patch: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<Operation[], AxiosResponse<App>>(
`${BASE_URL}/${id}`,
patch,
configOptions
patch
);

return response.data;
Expand Down
7 changes: 1 addition & 6 deletions openmetadata-ui/src/main/resources/ui/src/rest/chartAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ export const getChartById = async (id: string, params?: ListParams) => {
};

export const updateChart = async (id: string, data: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<Operation[], AxiosResponse<ChartType>>(
`/charts/${id}`,
data,
configOptions
data
);

return response.data;
Expand Down
31 changes: 14 additions & 17 deletions openmetadata-ui/src/main/resources/ui/src/rest/dashboardAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import { AxiosResponse } from 'axios';
import { Operation } from 'fast-json-patch';
import { PagingResponse, PagingWithoutTotal, RestoreRequestType } from 'Models';
import { QueryVote } from '../components/TableQueries/TableQueries.interface';
import { PAGE_SIZE } from '../constants/constants';
import {
APPLICATION_JSON_CONTENT_TYPE_HEADER,
PAGE_SIZE,
} from '../constants/constants';
import { Dashboard } from '../generated/entity/data/dashboard';
import { EntityHistory } from '../generated/type/entityHistory';
import { EntityReference } from '../generated/type/entityReference';
Expand Down Expand Up @@ -87,41 +90,35 @@ export const getDashboardByFqn = async (fqn: string, params?: ListParams) => {
};

export const addFollower = async (dashboardID: string, userId: string) => {
const configOptions = {
headers: { 'Content-type': 'application/json' },
};

const response = await APIClient.put<
string,
AxiosResponse<{
changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] };
}>
>(`${BASE_URL}/${dashboardID}/followers`, userId, configOptions);
>(
`${BASE_URL}/${dashboardID}/followers`,
userId,
APPLICATION_JSON_CONTENT_TYPE_HEADER
);

return response.data;
};

export const removeFollower = async (dashboardID: string, userId: string) => {
const configOptions = {
headers: { 'Content-type': 'application/json' },
};

const response = await APIClient.delete<{
changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] };
}>(`${BASE_URL}/${dashboardID}/followers/${userId}`, configOptions);
}>(
`${BASE_URL}/${dashboardID}/followers/${userId}`,
APPLICATION_JSON_CONTENT_TYPE_HEADER
);

return response.data;
};

export const patchDashboardDetails = async (id: string, data: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<Operation[], AxiosResponse<Dashboard>>(
`${BASE_URL}/${id}`,
data,
configOptions
data
);

return response.data;
Expand Down
15 changes: 4 additions & 11 deletions openmetadata-ui/src/main/resources/ui/src/rest/dataModelsAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AxiosResponse } from 'axios';
import { Operation } from 'fast-json-patch';
import { RestoreRequestType } from 'Models';
import { QueryVote } from '../components/TableQueries/TableQueries.interface';
import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants';
import { DashboardDataModel } from '../generated/entity/data/dashboardDataModel';
import { EntityHistory } from '../generated/type/entityHistory';
import { EntityReference } from '../generated/type/entityReference';
Expand All @@ -24,14 +25,6 @@ import APIClient from './index';

const URL = '/dashboard/datamodels';

const configOptionsForPatch = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const configOptions = {
headers: { 'Content-type': 'application/json' },
};

export const getDataModelByFqn = async (fqn: string, params?: ListParams) => {
const response = await APIClient.get<DashboardDataModel>(
`${URL}/name/${getEncodedFqn(fqn)}`,
Expand All @@ -50,7 +43,7 @@ export const patchDataModelDetails = async (id: string, data: Operation[]) => {
const response = await APIClient.patch<
Operation[],
AxiosResponse<DashboardDataModel>
>(`${URL}/${id}`, data, configOptionsForPatch);
>(`${URL}/${id}`, data);

return response.data;
};
Expand All @@ -61,7 +54,7 @@ export const addDataModelFollower = async (id: string, userId: string) => {
AxiosResponse<{
changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] };
}>
>(`${URL}/${id}/followers`, userId, configOptions);
>(`${URL}/${id}/followers`, userId, APPLICATION_JSON_CONTENT_TYPE_HEADER);

return response.data;
};
Expand All @@ -72,7 +65,7 @@ export const removeDataModelFollower = async (id: string, userId: string) => {
AxiosResponse<{
changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] };
}>
>(`${URL}/${id}/followers/${userId}`, configOptions);
>(`${URL}/${id}/followers/${userId}`, APPLICATION_JSON_CONTENT_TYPE_HEADER);

return response.data;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ export const addDataProducts = async (data: CreateDataProduct) => {
};

export const patchDataProduct = async (id: string, patch: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<
Operation[],
AxiosResponse<DataProduct>
>(`${BASE_URL}/${id}`, patch, configOptions);
>(`${BASE_URL}/${id}`, patch);

return response.data;
};
Expand Down
13 changes: 2 additions & 11 deletions openmetadata-ui/src/main/resources/ui/src/rest/databaseAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,9 @@ export const getDatabaseDetailsByFQN = async (
};

export const patchDatabaseDetails = async (id: string, data: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<Operation[], AxiosResponse<Database>>(
`/databases/${id}`,
data,
configOptions
data
);

return response.data;
Expand All @@ -87,14 +82,10 @@ export const patchDatabaseSchemaDetails = async (
id: string,
data: Operation[]
) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<
Operation[],
AxiosResponse<DatabaseSchema>
>(`/databaseSchemas/${id}`, data, configOptions);
>(`/databaseSchemas/${id}`, data);

return response.data;
};
Expand Down
7 changes: 1 addition & 6 deletions openmetadata-ui/src/main/resources/ui/src/rest/domainAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ export const addDomains = async (data: CreateDomain) => {
};

export const patchDomains = async (id: string, patch: Operation[]) => {
const configOptions = {
headers: { 'Content-type': 'application/json-patch+json' },
};

const response = await APIClient.patch<Operation[], AxiosResponse<Domain>>(
`/domains/${id}`,
patch,
configOptions
patch
);

return response.data;
Expand Down
7 changes: 2 additions & 5 deletions openmetadata-ui/src/main/resources/ui/src/rest/feedsAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import { AxiosResponse } from 'axios';
import { Operation } from 'fast-json-patch';
import { isUndefined } from 'lodash';
import { configOptions } from '../constants/constants';
import { TaskOperation } from '../constants/Feeds.constants';
import { FeedFilter } from '../enums/mydata.enum';
import { CloseTask } from '../generated/api/feed/closeTask';
Expand Down Expand Up @@ -133,8 +132,7 @@ export const deletePostById = (threadId: string, postId: string) => {
export const updateThread = async (threadId: string, data: Operation[]) => {
const response = await APIClient.patch<Operation[], AxiosResponse<Thread>>(
`/feed/${threadId}`,
data,
configOptions
data
);

return response.data;
Expand All @@ -147,8 +145,7 @@ export const updatePost = async (
) => {
const response = await APIClient.patch<Operation[], AxiosResponse<Thread>>(
`/feed/${threadId}/posts/${postId}`,
data,
configOptions
data
);

return response.data;
Expand Down
Loading

0 comments on commit c7e6619

Please sign in to comment.