create windmill get all workspaces list function

This commit is contained in:
Sunil Kumar
2023-07-17 16:50:27 +05:30
parent 6125246794
commit 04611d980b
+36
View File
@@ -32,6 +32,8 @@ import {
INTEGRATION_TRAVISCI_API_URL, INTEGRATION_TRAVISCI_API_URL,
INTEGRATION_VERCEL, INTEGRATION_VERCEL,
INTEGRATION_VERCEL_API_URL, INTEGRATION_VERCEL_API_URL,
INTEGRATION_WINDMILL,
INTEGRATION_WINDMILL_API_URL,
} from "../variables"; } from "../variables";
interface App { interface App {
@@ -145,6 +147,11 @@ const getApps = async ({
accountId: accessId accountId: accessId
}) })
break; break;
case INTEGRATION_WINDMILL:
apps = await getAppsWindmill({
accessToken,
});
break;
} }
return apps; return apps;
@@ -721,4 +728,33 @@ const getAppsCloudflarePages = async ({
return apps; return apps;
} }
/**
* Return list of projects for Windmill integration
* @param {Object} obj
* @param {String} obj.accessToken - access token for Windmill API
* @returns {Object[]} apps - names of Windmill workspaces
* @returns {String} apps.name - name of Windmill workspace
*/
const getAppsWindmill = async ({ accessToken }: { accessToken: string }) => {
const { data } = await standardRequest.get(
`${INTEGRATION_WINDMILL_API_URL}/workspaces/list`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
"Accept-Encoding": "application/json",
},
}
);
const apps = data.map((a: any) => {
return {
name: a.name,
appId: a.id,
};
});
return apps;
};
export { getApps }; export { getApps };