Skip to content

Commit

Permalink
Merge pull request #3045 from dlabrecq/revert
Browse files Browse the repository at this point in the history
Revert previous API update
  • Loading branch information
dlabrecq authored Apr 4, 2023
2 parents 5ac74fa + 567743d commit 4a9d696
Show file tree
Hide file tree
Showing 68 changed files with 128 additions and 598 deletions.
10 changes: 1 addition & 9 deletions src/api/accountSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from 'axios';

import type { PagedLinks, PagedMetaData } from './api';
import type { AwsOcpTag } from './tags/awsOcpTags';

export interface AccountSettingsData {
cost_type?: string;
Expand All @@ -15,12 +14,5 @@ export interface AccountSettings {
}

export function fetchAccountSettings() {
const fetch = () => axios.get<AwsOcpTag>(`account-settings/`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<AccountSettings>(`account-settings/`);
}
45 changes: 5 additions & 40 deletions src/api/costModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,21 @@ export interface CostModelRequest {
export type CostModels = PagedResponse<CostModel>;

export function fetchCostModels(query = '') {
const fetch = () => axios.get<CostModels>(`cost-models/${query && '?'}${query}`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<CostModels>(`cost-models/${query && '?'}${query}`);
}

export function fetchCostModel(uuid: string) {
const fetch = () => axios.get<CostModels>(`cost-models/${uuid}/`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<CostModels>(`cost-models/${uuid}/`);
}

export function addCostModel(request: CostModelRequest) {
const fetch = () => axios.post(`cost-models/`, request);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.post(`cost-models/`, request);
}

export function updateCostModel(uuid: string, request: CostModelRequest) {
const fetch = () => axios.put(`cost-models/${uuid}/`, request);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.put(`cost-models/${uuid}/`, request);
}

export function deleteCostModel(uuid: string) {
const fetch = () => axios.delete(`cost-models/${uuid}/`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.delete(`cost-models/${uuid}/`);
}
18 changes: 5 additions & 13 deletions src/api/export/awsExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/awsOcpExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/azureExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/azureOcpExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/gcpExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/gcpOcpExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/ibmExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/ociExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/ocpCloudExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/ocpExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
18 changes: 5 additions & 13 deletions src/api/export/rhelExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
const fetch = () =>
axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
});
}
9 changes: 1 addition & 8 deletions src/api/forecasts/awsForecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial<Record<ForecastType, string>> = {

export function runForecast(forecastType: ForecastType, query: string) {
const path = ForecastTypePaths[forecastType];
const fetch = () => axios.get<Forecast>(`${path}?${query}`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<Forecast>(`${path}?${query}`);
}
9 changes: 1 addition & 8 deletions src/api/forecasts/awsOcpForecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial<Record<ForecastType, string>> = {

export function runForecast(forecastType: ForecastType, query: string) {
const path = ForecastTypePaths[forecastType];
const fetch = () => axios.get<Forecast>(`${path}?${query}`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<Forecast>(`${path}?${query}`);
}
9 changes: 1 addition & 8 deletions src/api/forecasts/azureForecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial<Record<ForecastType, string>> = {

export function runForecast(forecastType: ForecastType, query: string) {
const path = ForecastTypePaths[forecastType];
const fetch = () => axios.get<Forecast>(`${path}?${query}`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<Forecast>(`${path}?${query}`);
}
9 changes: 1 addition & 8 deletions src/api/forecasts/azureOcpForecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial<Record<ForecastType, string>> = {

export function runForecast(forecastType: ForecastType, query: string) {
const path = ForecastTypePaths[forecastType];
const fetch = () => axios.get<Forecast>(`${path}?${query}`);

const insights = (window as any).insights;
if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) {
return insights.chrome.auth.getUser().then(() => fetch());
} else {
return fetch();
}
return axios.get<Forecast>(`${path}?${query}`);
}
Loading

0 comments on commit 4a9d696

Please sign in to comment.