remove Authorization setting in NetworkService apis

This commit is contained in:
dongfang committed 2025-02-18 04:56:26 +00:00
1 parent 1410c23c99
commit 9e0532baf1
1 file changed
+29 -137
+29 -137
View File
@@ -75,7 +75,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.monitorId - The monitor ID to be sent in the param. * @param {string} config.monitorId - The monitor ID to be sent in the param.
* @returns {Promise<AxiosResponse>} The response from the axios GET request. * @returns {Promise<AxiosResponse>} The response from the axios GET request.
*/ */
@@ -83,7 +82,6 @@ class NetworkService {
async getMonitorById(config) { async getMonitorById(config) {
return this.axiosInstance.get(`/monitors/${config.monitorId}`, { return this.axiosInstance.get(`/monitors/${config.monitorId}`, {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -97,19 +95,13 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {Object} config.monitor - The monitor object to be sent in the request body. * @param {Object} config.monitor - The monitor object to be sent in the request body.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/ */
async createMonitor(config) { async createMonitor(config) {
const { authToken, monitor } = config; const { monitor } = config;
return this.axiosInstance.post(`/monitors`, monitor, { return this.axiosInstance.post(`/monitors`, monitor);
headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json",
},
});
} }
/** /**
@@ -120,19 +112,17 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {Object} config.monitorURL - The monitor url to be sent in the request body. * @param {Object} config.monitorURL - The monitor url to be sent in the request body.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/ */
async checkEndpointResolution(config) { async checkEndpointResolution(config) {
const { authToken, monitorURL } = config; const { monitorURL } = config;
const params = new URLSearchParams(); const params = new URLSearchParams();
if (monitorURL) params.append("monitorURL", monitorURL); if (monitorURL) params.append("monitorURL", monitorURL);
return this.axiosInstance.get(`/monitors/resolution/url?${params.toString()}`, { return this.axiosInstance.get(`/monitors/resolution/url?${params.toString()}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -146,7 +136,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.teamId - Team ID * @param {string} config.teamId - Team ID
* @param {Array<string>} config.types - Array of monitor types * @param {Array<string>} config.types - Array of monitor types
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
@@ -163,7 +152,6 @@ class NetworkService {
`/monitors/team/summary/${config.teamId}?${params.toString()}`, `/monitors/team/summary/${config.teamId}?${params.toString()}`,
{ {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} }
@@ -177,7 +165,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.teamId - The ID of the team whose monitors are to be retrieved. * @param {string} config.teamId - The ID of the team whose monitors are to be retrieved.
* @param {number} [config.limit] - The maximum number of checks to retrieve. 0 for all, -1 for none * @param {number} [config.limit] - The maximum number of checks to retrieve. 0 for all, -1 for none
* @param {Array<string>} [config.types] - The types of monitors to retrieve. * @param {Array<string>} [config.types] - The types of monitors to retrieve.
@@ -190,7 +177,7 @@ class NetworkService {
*/ */
async getMonitorsByTeamId(config) { async getMonitorsByTeamId(config) {
const { authToken, teamId, limit, types, page, rowsPerPage, filter, field, order } = const { teamId, limit, types, page, rowsPerPage, filter, field, order } =
config; config;
const params = new URLSearchParams(); const params = new URLSearchParams();
@@ -208,7 +195,6 @@ class NetworkService {
return this.axiosInstance.get(`/monitors/team/${teamId}?${params.toString()}`, { return this.axiosInstance.get(`/monitors/team/${teamId}?${params.toString()}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -221,7 +207,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.monitorId - The ID of the monitor whose statistics are to be retrieved. * @param {string} config.monitorId - The ID of the monitor whose statistics are to be retrieved.
* @param {string} config.sortOrder - The order in which to sort the retrieved statistics. * @param {string} config.sortOrder - The order in which to sort the retrieved statistics.
* @param {number} config.limit - The maximum number of statistics to retrieve. * @param {number} config.limit - The maximum number of statistics to retrieve.
@@ -239,13 +224,7 @@ class NetworkService {
if (config.normalize) params.append("normalize", config.normalize); if (config.normalize) params.append("normalize", config.normalize);
return this.axiosInstance.get( return this.axiosInstance.get(
`/monitors/stats/${config.monitorId}?${params.toString()}`, `/monitors/stats/${config.monitorId}?${params.toString()}`);
{
headers: {
Authorization: `Bearer ${config.authToken}`,
},
}
);
} }
async getHardwareDetailsByMonitorId(config) { async getHardwareDetailsByMonitorId(config) {
@@ -253,13 +232,7 @@ class NetworkService {
if (config.dateRange) params.append("dateRange", config.dateRange); if (config.dateRange) params.append("dateRange", config.dateRange);
return this.axiosInstance.get( return this.axiosInstance.get(
`/monitors/hardware/details/${config.monitorId}?${params.toString()}`, `/monitors/hardware/details/${config.monitorId}?${params.toString()}`);
{
headers: {
Authorization: `Bearer ${config.authToken}`,
},
}
);
} }
async getUptimeDetailsById(config) { async getUptimeDetailsById(config) {
const params = new URLSearchParams(); const params = new URLSearchParams();
@@ -267,13 +240,7 @@ class NetworkService {
if (config.normalize) params.append("normalize", config.normalize); if (config.normalize) params.append("normalize", config.normalize);
return this.axiosInstance.get( return this.axiosInstance.get(
`/monitors/uptime/details/${config.monitorId}?${params.toString()}`, `/monitors/uptime/details/${config.monitorId}?${params.toString()}`);
{
headers: {
Authorization: `Bearer ${config.authToken}`,
},
}
);
} }
/** /**
@@ -283,13 +250,12 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.monitorId - The ID of the monitor to be updated. * @param {string} config.monitorId - The ID of the monitor to be updated.
* @param {Object} config.updatedFields - The fields to be updated for the monitor. * @param {Object} config.updatedFields - The fields to be updated for the monitor.
* @returns {Promise<AxiosResponse>} The response from the axios PUT request. * @returns {Promise<AxiosResponse>} The response from the axios PUT request.
*/ */
async updateMonitor(config) { async updateMonitor(config) {
const { authToken, monitorId, monitor } = config; const { monitorId, monitor } = config;
const updatedFields = { const updatedFields = {
name: monitor.name, name: monitor.name,
description: monitor.description, description: monitor.description,
@@ -298,7 +264,6 @@ class NetworkService {
}; };
return this.axiosInstance.put(`/monitors/${monitorId}`, updatedFields, { return this.axiosInstance.put(`/monitors/${monitorId}`, updatedFields, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -311,14 +276,12 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.monitorId - The ID of the monitor to be deleted. * @param {string} config.monitorId - The ID of the monitor to be deleted.
* @returns {Promise<AxiosResponse>} The response from the axios DELETE request. * @returns {Promise<AxiosResponse>} The response from the axios DELETE request.
*/ */
async deleteMonitorById(config) { async deleteMonitorById(config) {
return this.axiosInstance.delete(`/monitors/${config.monitorId}`, { return this.axiosInstance.delete(`/monitors/${config.monitorId}`, {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -331,14 +294,12 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.teamId - The team ID of the monitors to be deleted. * @param {string} config.teamId - The team ID of the monitors to be deleted.
* @returns {Promise<AxiosResponse>} The response from the axios DELETE request. * @returns {Promise<AxiosResponse>} The response from the axios DELETE request.
*/ */
async deleteChecksByTeamId(config) { async deleteChecksByTeamId(config) {
return this.axiosInstance.delete(`/checks/team/${config.teamId}`, { return this.axiosInstance.delete(`/checks/team/${config.teamId}`, {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -350,7 +311,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.monitorId - The ID of the monitor to be paused. * @param {string} config.monitorId - The ID of the monitor to be paused.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/ */
@@ -360,7 +320,6 @@ class NetworkService {
{}, {},
{ {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} }
@@ -374,7 +333,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/ */
async addDemoMonitors(config) { async addDemoMonitors(config) {
@@ -383,7 +341,6 @@ class NetworkService {
{}, {},
{ {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} }
@@ -397,13 +354,11 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @returns {Promise<AxiosResponse>} The response from the axios DELETE request. * @returns {Promise<AxiosResponse>} The response from the axios DELETE request.
*/ */
async deleteAllMonitors(config) { async deleteAllMonitors(config) {
return this.axiosInstance.delete(`/monitors/`, { return this.axiosInstance.delete(`/monitors/`, {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -416,17 +371,12 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.monitorId - The ID of the monitor whose certificate expiry is to be retrieved. * @param {string} config.monitorId - The ID of the monitor whose certificate expiry is to be retrieved.
* @returns {Promise<AxiosResponse>} The response from the axios GET request. * @returns {Promise<AxiosResponse>} The response from the axios GET request.
* *
*/ */
async getCertificateExpiry(config) { async getCertificateExpiry(config) {
return this.axiosInstance.get(`/monitors/certificate/${config.monitorId}`, { return this.axiosInstance.get(`/monitors/certificate/${config.monitorId}`);
headers: {
Authorization: `Bearer ${config.authToken}`,
},
});
} }
/** /**
@@ -463,18 +413,13 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.userId - The ID of the user to be updated. * @param {string} config.userId - The ID of the user to be updated.
* @param {Object} config.form - The form data for the user to be updated. * @param {Object} config.form - The form data for the user to be updated.
* @returns {Promise<AxiosResponse>} The response from the axios PUT request. * @returns {Promise<AxiosResponse>} The response from the axios PUT request.
* *
*/ */
async updateUser(config) { async updateUser(config) {
return this.axiosInstance.put(`/auth/user/${config.userId}`, config.form, { return this.axiosInstance.put(`/auth/user/${config.userId}`, config.form);
headers: {
Authorization: `Bearer ${config.authToken}`,
},
});
} }
/** /**
@@ -484,14 +429,11 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.userId - The ID of the user to be deleted. * @param {string} config.userId - The ID of the user to be deleted.
* *
**/ **/
async deleteUser(config) { async deleteUser(config) {
return this.axiosInstance.delete(`/auth/user/${config.userId}`, { return this.axiosInstance.delete(`/auth/user/${config.userId}`);
headers: { Authorization: `Bearer ${config.authToken}` },
});
} }
/** /**
@@ -564,14 +506,11 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @returns {Promise<AxiosResponse>} The response from the axios GET request. * @returns {Promise<AxiosResponse>} The response from the axios GET request.
* *
*/ */
async getAllUsers(config) { async getAllUsers(config) {
return this.axiosInstance.get("/auth/users", { return this.axiosInstance.get("/auth/users");
headers: { Authorization: `Bearer ${config.authToken}` },
});
} }
/** /**
@@ -581,7 +520,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.email - The email of the user to be invited. * @param {string} config.email - The email of the user to be invited.
* @param {string} config.role - The role of the user to be invited. * @param {string} config.role - The role of the user to be invited.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
@@ -591,9 +529,6 @@ class NetworkService {
return this.axiosInstance.post( return this.axiosInstance.post(
`/invite`, `/invite`,
{ email: config.email, role: config.role }, { email: config.email, role: config.role },
{
headers: { Authorization: `Bearer ${config.authToken}` },
}
); );
} }
@@ -620,7 +555,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.monitorId - The ID of the monitor. * @param {string} config.monitorId - The ID of the monitor.
* @param {string} config.sortOrder - The order in which to sort the checks. * @param {string} config.sortOrder - The order in which to sort the checks.
* @param {number} config.limit - The maximum number of checks to retrieve. * @param {number} config.limit - The maximum number of checks to retrieve.
@@ -642,9 +576,7 @@ class NetworkService {
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage); if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
if (config.status !== undefined) params.append("status", config.status); if (config.status !== undefined) params.append("status", config.status);
return this.axiosInstance.get(`/checks/${config.monitorId}?${params.toString()}`, { return this.axiosInstance.get(`/checks/${config.monitorId}?${params.toString()}`);
headers: { Authorization: `Bearer ${config.authToken}` },
});
} }
/** /**
@@ -654,7 +586,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} config.userId - The ID of the user. * @param {string} config.userId - The ID of the user.
* @param {string} config.sortOrder - The order in which to sort the checks. * @param {string} config.sortOrder - The order in which to sort the checks.
* @param {number} config.limit - The maximum number of checks to retrieve. * @param {number} config.limit - The maximum number of checks to retrieve.
@@ -674,9 +605,7 @@ class NetworkService {
if (config.page) params.append("page", config.page); if (config.page) params.append("page", config.page);
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage); if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
if (config.status !== undefined) params.append("status", config.status); if (config.status !== undefined) params.append("status", config.status);
return this.axiosInstance.get(`/checks/team/${config.teamId}?${params.toString()}`, { return this.axiosInstance.get(`/checks/team/${config.teamId}?${params.toString()}`);
headers: { Authorization: `Bearer ${config.authToken}` },
});
} }
/** /**
@@ -686,7 +615,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {number} config.ttl - TTL for checks * @param {number} config.ttl - TTL for checks
* @returns {Promise<AxiosResponse>} The response from the axios GET request. * @returns {Promise<AxiosResponse>} The response from the axios GET request.
* *
@@ -697,7 +625,6 @@ class NetworkService {
{ ttl: config.ttl }, { ttl: config.ttl },
{ {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} }
@@ -711,7 +638,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @returns {Promise<AxiosResponse>} The response from the axios GET request. * @returns {Promise<AxiosResponse>} The response from the axios GET request.
* *
*/ */
@@ -719,7 +645,6 @@ class NetworkService {
async getAppSettings(config) { async getAppSettings(config) {
return this.axiosInstance.get("/settings", { return this.axiosInstance.get("/settings", {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -733,14 +658,12 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {Object} config.settings - The monitor object to be sent in the request body. * @param {Object} config.settings - The monitor object to be sent in the request body.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/ */
async updateAppSettings(config) { async updateAppSettings(config) {
return this.axiosInstance.put(`/settings`, config.settings, { return this.axiosInstance.put(`/settings`, config.settings, {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -753,7 +676,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {Object} config.maintenanceWindow - The maintenance window object to be sent in the request body. * @param {Object} config.maintenanceWindow - The maintenance window object to be sent in the request body.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
* *
@@ -762,7 +684,6 @@ class NetworkService {
async createMaintenanceWindow(config) { async createMaintenanceWindow(config) {
return this.axiosInstance.post(`/maintenance-window`, config.maintenanceWindow, { return this.axiosInstance.post(`/maintenance-window`, config.maintenanceWindow, {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -775,7 +696,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {Object} config.maintenanceWindowId - The maintenance window id. * @param {Object} config.maintenanceWindowId - The maintenance window id.
* @param {Object} config.maintenanceWindow - The maintenance window object to be sent in the request body. * @param {Object} config.maintenanceWindow - The maintenance window object to be sent in the request body.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
@@ -788,7 +708,6 @@ class NetworkService {
config.maintenanceWindow, config.maintenanceWindow,
{ {
headers: { headers: {
Authorization: `Bearer ${config.authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
} }
@@ -802,17 +721,15 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} [config.maintenanceWindowId] - The id of the maintenance window to delete. * @param {string} [config.maintenanceWindowId] - The id of the maintenance window to delete.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
* *
*/ */
async getMaintenanceWindowById(config) { async getMaintenanceWindowById(config) {
const { authToken, maintenanceWindowId } = config; const { maintenanceWindowId } = config;
return this.axiosInstance.get(`/maintenance-window/${maintenanceWindowId}`, { return this.axiosInstance.get(`/maintenance-window/${maintenanceWindowId}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -825,7 +742,6 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} [config.active] - The status of the maintenance windows to retrieve. * @param {string} [config.active] - The status of the maintenance windows to retrieve.
* @param {number} [config.page] - The page number for pagination. * @param {number} [config.page] - The page number for pagination.
* @param {number} [config.rowsPerPage] - The number of rows per page for pagination. * @param {number} [config.rowsPerPage] - The number of rows per page for pagination.
@@ -836,7 +752,7 @@ class NetworkService {
*/ */
async getMaintenanceWindowsByTeamId(config) { async getMaintenanceWindowsByTeamId(config) {
const { authToken, active, page, rowsPerPage, field, order } = config; const { active, page, rowsPerPage, field, order } = config;
const params = new URLSearchParams(); const params = new URLSearchParams();
if (active) params.append("status", active); if (active) params.append("status", active);
@@ -847,7 +763,6 @@ class NetworkService {
return this.axiosInstance.get(`/maintenance-window/team?${params.toString()}`, { return this.axiosInstance.get(`/maintenance-window/team?${params.toString()}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -859,17 +774,15 @@ class NetworkService {
* *
* @async * @async
* @param {Object} config - The configuration object. * @param {Object} config - The configuration object.
* @param {string} config.authToken - The authorization token to be used in the request header.
* @param {string} [config.maintenanceWindowId] - The id of the maintenance window to delete. * @param {string} [config.maintenanceWindowId] - The id of the maintenance window to delete.
* @returns {Promise<AxiosResponse>} The response from the axios POST request. * @returns {Promise<AxiosResponse>} The response from the axios POST request.
* *
*/ */
async deleteMaintenanceWindow(config) { async deleteMaintenanceWindow(config) {
const { authToken, maintenanceWindowId } = config; const { maintenanceWindowId } = config;
return this.axiosInstance.delete(`/maintenance-window/${maintenanceWindowId}`, { return this.axiosInstance.delete(`/maintenance-window/${maintenanceWindowId}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
@@ -892,7 +805,6 @@ class NetworkService {
subscribeToDistributedUptimeMonitors(config) { subscribeToDistributedUptimeMonitors(config) {
const { const {
authToken,
teamId, teamId,
onUpdate, onUpdate,
onError, onError,
@@ -925,15 +837,13 @@ class NetworkService {
} }
const url = `${this.axiosInstance.defaults.baseURL}/distributed-uptime/monitors/${teamId}?${params.toString()}`; const url = `${this.axiosInstance.defaults.baseURL}/distributed-uptime/monitors/${teamId}?${params.toString()}`;
this.eventSource = new EventSource(url, { this.eventSource = new EventSource(url);
headers: { Authorization: `Bearer ${authToken}` },
});
this.eventSource.onopen = () => { this.eventSource.onopen = () => {
onOpen?.(); onOpen?.();
}; };
this.eventSource.addEventListener("open", (e) => {}); this.eventSource.addEventListener("open", (e) => { });
this.eventSource.onmessage = (event) => { this.eventSource.onmessage = (event) => {
const data = JSON.parse(event.data); const data = JSON.parse(event.data);
@@ -960,15 +870,13 @@ class NetworkService {
subscribeToDistributedUptimeDetails(config) { subscribeToDistributedUptimeDetails(config) {
const params = new URLSearchParams(); const params = new URLSearchParams();
const { authToken, monitorId, onUpdate, onOpen, onError, dateRange, normalize } = const { monitorId, onUpdate, onOpen, onError, dateRange, normalize } =
config; config;
if (dateRange) params.append("dateRange", dateRange); if (dateRange) params.append("dateRange", dateRange);
if (normalize) params.append("normalize", normalize); if (normalize) params.append("normalize", normalize);
const url = `${this.axiosInstance.defaults.baseURL}/distributed-uptime/monitors/details/${monitorId}?${params.toString()}`; const url = `${this.axiosInstance.defaults.baseURL}/distributed-uptime/monitors/details/${monitorId}?${params.toString()}`;
this.eventSource = new EventSource(url, { this.eventSource = new EventSource(url);
headers: { Authorization: `Bearer ${authToken}` },
});
this.eventSource.onopen = (e) => { this.eventSource.onopen = (e) => {
onOpen?.(); onOpen?.();
@@ -992,41 +900,37 @@ class NetworkService {
}; };
} }
async getStatusPage(config) { async getStatusPage() {
const { authToken } = config;
return this.axiosInstance.get(`/status-page`, { return this.axiosInstance.get(`/status-page`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
} }
async getStatusPageByUrl(config) { async getStatusPageByUrl(config) {
const { authToken, url, type } = config; const { url, type } = config;
const params = new URLSearchParams(); const params = new URLSearchParams();
params.append("type", type); params.append("type", type);
return this.axiosInstance.get(`/status-page/${url}?${params.toString()}`, { return this.axiosInstance.get(`/status-page/${url}?${params.toString()}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
} }
async getStatusPagesByTeamId(config) { async getStatusPagesByTeamId(config) {
const { authToken, teamId } = config; const { teamId } = config;
return this.axiosInstance.get(`/status-page/team/${teamId}`, { return this.axiosInstance.get(`/status-page/team/${teamId}`, {
headers: { headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
} }
async createStatusPage(config) { async createStatusPage(config) {
const { authToken, user, form, isCreate } = config; const { user, form, isCreate } = config;
const fd = new FormData(); const fd = new FormData();
fd.append("teamId", user.teamId); fd.append("teamId", user.teamId);
@@ -1055,29 +959,17 @@ class NetworkService {
} }
} }
if (isCreate) { if (isCreate) {
return this.axiosInstance.post(`/status-page`, fd, { return this.axiosInstance.post(`/status-page`, fd);
headers: {
Authorization: `Bearer ${authToken}`,
},
});
} }
return this.axiosInstance.put(`/status-page`, fd, { return this.axiosInstance.put(`/status-page`, fd);
headers: {
Authorization: `Bearer ${authToken}`,
},
});
} }
async deleteStatusPage(config) { async deleteStatusPage(config) {
const { authToken, url } = config; const { url } = config;
const encodedUrl = encodeURIComponent(url); const encodedUrl = encodeURIComponent(url);
return this.axiosInstance.delete(`/status-page/${encodedUrl}`, { return this.axiosInstance.delete(`/status-page/${encodedUrl}`);
headers: {
Authorization: `Bearer ${authToken}`,
},
});
} }
} }