api.tsx 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492
  1. import { PolicyDocType } from "./auth/types";
  2. import { PullRequest } from "main/home/cluster-dashboard/preview-environments/types";
  3. import { baseApi } from "./baseApi";
  4. import { BuildConfig, FullActionConfigType } from "./types";
  5. import {
  6. CreateStackBody,
  7. SourceConfig,
  8. } from "main/home/cluster-dashboard/stacks/types";
  9. import {
  10. CreateRoleBody,
  11. UpdateRoleBody,
  12. } from "main/home/project-settings/roles-admin/types";
  13. /**
  14. * Generic api call format
  15. * @param {string} token - Bearer token.
  16. * @param {Object} params - Body params.
  17. * @param {Object} pathParams - Path params.
  18. * @param {(err: Object, res: Object) => void} callback - Callback function.
  19. */
  20. const checkAuth = baseApi("GET", "/api/users/current", {
  21. disableUnauthorizedPopup: true,
  22. });
  23. const connectECRRegistry = baseApi<
  24. {
  25. name: string;
  26. aws_integration_id: string;
  27. },
  28. { id: number }
  29. >("POST", (pathParams) => {
  30. return `/api/projects/${pathParams.id}/registries`;
  31. });
  32. const connectGCRRegistry = baseApi<
  33. {
  34. name: string;
  35. gcp_integration_id: string;
  36. url: string;
  37. },
  38. { id: number }
  39. >("POST", (pathParams) => {
  40. return `/api/projects/${pathParams.id}/registries`;
  41. });
  42. const connectDORegistry = baseApi<
  43. {
  44. name: string;
  45. do_integration_id: string;
  46. url: string;
  47. },
  48. { project_id: number }
  49. >("POST", (pathParams) => {
  50. return `/api/projects/${pathParams.project_id}/registries`;
  51. });
  52. const getAWSIntegration = baseApi<{}, { project_id: number }>(
  53. "GET",
  54. ({ project_id }) => `/api/projects/${project_id}/integrations/aws`
  55. );
  56. const getGCPIntegration = baseApi<{}, { project_id: number }>(
  57. "GET",
  58. ({ project_id }) => `/api/projects/${project_id}/integrations/gcp`
  59. );
  60. const getAzureIntegration = baseApi<{}, { project_id: number }>(
  61. "GET",
  62. ({ project_id }) => `/api/projects/${project_id}/integrations/azure`
  63. );
  64. const getGitlabIntegration = baseApi<{}, { project_id: number }>(
  65. "GET",
  66. ({ project_id }) => `/api/projects/${project_id}/integrations/gitlab`
  67. );
  68. const createAWSIntegration = baseApi<
  69. {
  70. aws_region: string;
  71. aws_cluster_id?: string;
  72. aws_access_key_id: string;
  73. aws_secret_access_key: string;
  74. },
  75. { id: number }
  76. >("POST", (pathParams) => {
  77. return `/api/projects/${pathParams.id}/integrations/aws`;
  78. });
  79. const overwriteAWSIntegration = baseApi<
  80. {
  81. aws_integration_id: number;
  82. aws_access_key_id: string;
  83. aws_secret_access_key: string;
  84. cluster_id: number;
  85. },
  86. {
  87. project_id: number;
  88. }
  89. >("POST", (pathParams) => {
  90. return `/api/projects/${pathParams.project_id}/integrations/aws/overwrite`;
  91. });
  92. const updateClusterName = baseApi<
  93. {
  94. name: string;
  95. aws_cluster_id?: string;
  96. },
  97. {
  98. project_id: number;
  99. cluster_id: number;
  100. }
  101. >("POST", (pathParams) => {
  102. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  103. });
  104. const createAzureIntegration = baseApi<
  105. {
  106. azure_client_id: string;
  107. azure_subscription_id: string;
  108. azure_tenant_id: string;
  109. service_principal_key: string;
  110. },
  111. { id: number }
  112. >("POST", (pathParams) => {
  113. return `/api/projects/${pathParams.id}/integrations/azure`;
  114. });
  115. const createGitlabIntegration = baseApi<
  116. {
  117. instance_url: string;
  118. client_id: string;
  119. client_secret: string;
  120. },
  121. { id: number }
  122. >("POST", (pathParams) => {
  123. return `/api/projects/${pathParams.id}/integrations/gitlab`;
  124. });
  125. const createEmailVerification = baseApi<{}, {}>("POST", (pathParams) => {
  126. return `/api/email/verify/initiate`;
  127. });
  128. const createEnvironment = baseApi<
  129. {
  130. name: string;
  131. mode: "auto" | "manual";
  132. disable_new_comments: boolean;
  133. git_repo_branches: string[];
  134. },
  135. {
  136. project_id: number;
  137. cluster_id: number;
  138. git_installation_id: number;
  139. git_repo_owner: string;
  140. git_repo_name: string;
  141. }
  142. >("POST", (pathParams) => {
  143. let {
  144. project_id,
  145. cluster_id,
  146. git_installation_id,
  147. git_repo_owner,
  148. git_repo_name,
  149. } = pathParams;
  150. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  151. });
  152. const updateEnvironment = baseApi<
  153. {
  154. mode: "auto" | "manual";
  155. disable_new_comments: boolean;
  156. git_repo_branches: string[]; // Array with branch names
  157. },
  158. {
  159. project_id: number;
  160. cluster_id: number;
  161. environment_id: number;
  162. }
  163. >(
  164. "PATCH",
  165. ({ project_id, cluster_id, environment_id }) =>
  166. `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/settings`
  167. );
  168. const deleteEnvironment = baseApi<
  169. {
  170. name: string;
  171. },
  172. {
  173. project_id: number;
  174. cluster_id: number;
  175. git_installation_id: number;
  176. git_repo_owner: string;
  177. git_repo_name: string;
  178. }
  179. >("DELETE", (pathParams) => {
  180. let {
  181. project_id,
  182. cluster_id,
  183. git_installation_id,
  184. git_repo_owner,
  185. git_repo_name,
  186. } = pathParams;
  187. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/environment`;
  188. });
  189. const createPreviewEnvironmentDeployment = baseApi<
  190. PullRequest,
  191. { project_id: number; cluster_id: number }
  192. >(
  193. "POST",
  194. ({ project_id, cluster_id }) =>
  195. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/pull_request`
  196. );
  197. const reenablePreviewEnvironmentDeployment = baseApi<
  198. {},
  199. {
  200. project_id: number;
  201. cluster_id: number;
  202. deployment_id: number;
  203. }
  204. >(
  205. "PATCH",
  206. ({ project_id, cluster_id, deployment_id }) =>
  207. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/reenable`
  208. );
  209. const listEnvironments = baseApi<
  210. {},
  211. {
  212. project_id: number;
  213. cluster_id: number;
  214. }
  215. >("GET", (pathParams) => {
  216. let { project_id, cluster_id } = pathParams;
  217. return `/api/projects/${project_id}/clusters/${cluster_id}/environments`;
  218. });
  219. const getEnvironment = baseApi<
  220. {},
  221. {
  222. project_id: number;
  223. cluster_id: number;
  224. environment_id: number;
  225. }
  226. >("GET", (pathParams) => {
  227. let { project_id, cluster_id, environment_id } = pathParams;
  228. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}`;
  229. });
  230. const toggleNewCommentForEnvironment = baseApi<
  231. {
  232. disable: boolean;
  233. },
  234. {
  235. project_id: number;
  236. cluster_id: number;
  237. environment_id: number;
  238. }
  239. >("PATCH", (pathParams) => {
  240. let { project_id, cluster_id, environment_id } = pathParams;
  241. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/toggle_new_comment`;
  242. });
  243. const createGCPIntegration = baseApi<
  244. {
  245. gcp_key_data: string;
  246. gcp_project_id: string;
  247. },
  248. {
  249. project_id: number;
  250. }
  251. >("POST", (pathParams) => {
  252. return `/api/projects/${pathParams.project_id}/integrations/gcp`;
  253. });
  254. const createInvite = baseApi<
  255. {
  256. email: string;
  257. roles: string[];
  258. // legacy field
  259. kind: string;
  260. },
  261. {
  262. id: number;
  263. }
  264. >("POST", (pathParams) => {
  265. return `/api/projects/${pathParams.id}/invites`;
  266. });
  267. const createPasswordReset = baseApi<
  268. {
  269. email: string;
  270. },
  271. {}
  272. >("POST", (pathParams) => {
  273. return `/api/password/reset/initiate`;
  274. });
  275. const createPasswordResetVerify = baseApi<
  276. {
  277. email: string;
  278. token: string;
  279. token_id: number;
  280. },
  281. {}
  282. >("POST", (pathParams) => {
  283. return `/api/password/reset/verify`;
  284. });
  285. const createPasswordResetFinalize = baseApi<
  286. {
  287. email: string;
  288. token: string;
  289. token_id: number;
  290. new_password: string;
  291. },
  292. {}
  293. >("POST", (pathParams) => {
  294. return `/api/password/reset/finalize`;
  295. });
  296. const createProject = baseApi<{ name: string }, {}>("POST", (pathParams) => {
  297. return `/api/projects`;
  298. });
  299. const createSubdomain = baseApi<
  300. {},
  301. {
  302. id: number;
  303. release_name: string;
  304. namespace: string;
  305. cluster_id: number;
  306. }
  307. >("POST", (pathParams) => {
  308. let { cluster_id, id, namespace, release_name } = pathParams;
  309. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/subdomain`;
  310. });
  311. const deleteCluster = baseApi<
  312. {},
  313. {
  314. project_id: number;
  315. cluster_id: number;
  316. }
  317. >("DELETE", (pathParams) => {
  318. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  319. });
  320. const deleteInvite = baseApi<{}, { id: number; invId: number }>(
  321. "DELETE",
  322. (pathParams) => {
  323. return `/api/projects/${pathParams.id}/invites/${pathParams.invId}`;
  324. }
  325. );
  326. const deletePod = baseApi<
  327. {},
  328. { name: string; namespace: string; id: number; cluster_id: number }
  329. >("DELETE", (pathParams) => {
  330. let { id, name, cluster_id, namespace } = pathParams;
  331. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`;
  332. });
  333. const getPodEvents = baseApi<
  334. {},
  335. { name: string; namespace: string; id: number; cluster_id: number }
  336. >("GET", (pathParams) => {
  337. let { id, name, cluster_id, namespace } = pathParams;
  338. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}/events`;
  339. });
  340. const deleteProject = baseApi<{}, { id: number }>("DELETE", (pathParams) => {
  341. return `/api/projects/${pathParams.id}`;
  342. });
  343. const deleteRegistryIntegration = baseApi<
  344. {},
  345. {
  346. project_id: number;
  347. registry_id: number;
  348. }
  349. >("DELETE", (pathParams) => {
  350. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}`;
  351. });
  352. const deleteSlackIntegration = baseApi<
  353. {},
  354. {
  355. project_id: number;
  356. slack_integration_id: number;
  357. }
  358. >("DELETE", (pathParams) => {
  359. return `/api/projects/${pathParams.project_id}/slack_integrations/${pathParams.slack_integration_id}`;
  360. });
  361. const updateNotificationConfig = baseApi<
  362. {
  363. payload: any;
  364. },
  365. {
  366. project_id: number;
  367. cluster_id: number;
  368. namespace: string;
  369. name: string;
  370. }
  371. >("POST", (pathParams) => {
  372. let { project_id, cluster_id, namespace, name } = pathParams;
  373. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  374. });
  375. const getPRDeploymentList = baseApi<
  376. {
  377. environment_id?: number;
  378. },
  379. {
  380. cluster_id: number;
  381. project_id: number;
  382. }
  383. >("GET", (pathParams) => {
  384. const { cluster_id, project_id } = pathParams;
  385. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments`;
  386. });
  387. const getPRDeploymentByEnvironment = baseApi<
  388. {
  389. namespace: string;
  390. },
  391. {
  392. cluster_id: number;
  393. project_id: number;
  394. environment_id: number;
  395. }
  396. >("GET", (pathParams) => {
  397. const { cluster_id, project_id, environment_id } = pathParams;
  398. return `/api/projects/${project_id}/clusters/${cluster_id}/environments/${environment_id}/deployment`;
  399. });
  400. const getPRDeployment = baseApi<
  401. {
  402. namespace: string;
  403. },
  404. {
  405. cluster_id: number;
  406. project_id: number;
  407. git_installation_id: number;
  408. git_repo_owner: string;
  409. git_repo_name: string;
  410. }
  411. >("GET", (pathParams) => {
  412. const {
  413. cluster_id,
  414. project_id,
  415. git_installation_id,
  416. git_repo_owner,
  417. git_repo_name,
  418. } = pathParams;
  419. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${git_repo_owner}/${git_repo_name}/clusters/${cluster_id}/deployment`;
  420. });
  421. const deletePRDeployment = baseApi<
  422. {},
  423. {
  424. cluster_id: number;
  425. project_id: number;
  426. deployment_id: number;
  427. }
  428. >("DELETE", (pathParams) => {
  429. const { cluster_id, project_id, deployment_id } = pathParams;
  430. return `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}`;
  431. });
  432. const getNotificationConfig = baseApi<
  433. {},
  434. {
  435. project_id: number;
  436. cluster_id: number;
  437. namespace: string;
  438. name: string;
  439. }
  440. >("GET", (pathParams) => {
  441. let { project_id, cluster_id, namespace, name } = pathParams;
  442. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/notifications`;
  443. });
  444. const getGHAWorkflowTemplate = baseApi<
  445. {
  446. release_name: string;
  447. github_action_config: FullActionConfigType;
  448. },
  449. {
  450. cluster_id: number;
  451. project_id: number;
  452. namespace: string;
  453. }
  454. >("POST", (pathParams) => {
  455. const { cluster_id, project_id, namespace } = pathParams;
  456. return `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/gha_template`;
  457. });
  458. const deployTemplate = baseApi<
  459. {
  460. template_name: string;
  461. template_version: string;
  462. image_url?: string;
  463. values?: any;
  464. name: string;
  465. git_action_config?: FullActionConfigType;
  466. build_config?: any;
  467. synced_env_groups?: string[];
  468. },
  469. {
  470. id: number;
  471. cluster_id: number;
  472. namespace: string;
  473. repo_url?: string;
  474. }
  475. >("POST", (pathParams) => {
  476. let { cluster_id, id, namespace, repo_url } = pathParams;
  477. if (repo_url) {
  478. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases?repo_url=${repo_url}`;
  479. }
  480. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases`;
  481. });
  482. const deployAddon = baseApi<
  483. {
  484. template_name: string;
  485. template_version: string;
  486. values?: any;
  487. name: string;
  488. },
  489. {
  490. id: number;
  491. cluster_id: number;
  492. namespace: string;
  493. repo_url?: string;
  494. }
  495. >("POST", (pathParams) => {
  496. let { cluster_id, id, namespace, repo_url } = pathParams;
  497. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/addons?repo_url=${repo_url}`;
  498. });
  499. const detectBuildpack = baseApi<
  500. {},
  501. {
  502. project_id: number;
  503. git_repo_id: number;
  504. kind: string;
  505. owner: string;
  506. name: string;
  507. branch: string;
  508. }
  509. >("GET", (pathParams) => {
  510. return `/api/projects/${pathParams.project_id}/gitrepos/${
  511. pathParams.git_repo_id
  512. }/repos/${pathParams.kind}/${pathParams.owner}/${
  513. pathParams.name
  514. }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
  515. });
  516. const detectGitlabBuildpack = baseApi<
  517. { dir: string },
  518. {
  519. project_id: number;
  520. integration_id: number;
  521. repo_owner: string;
  522. repo_name: string;
  523. branch: string;
  524. }
  525. >(
  526. "GET",
  527. ({ project_id, integration_id, repo_name, repo_owner, branch }) =>
  528. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/buildpack/detect`
  529. );
  530. const getBranchContents = baseApi<
  531. {
  532. dir: string;
  533. },
  534. {
  535. project_id: number;
  536. git_repo_id: number;
  537. kind: string;
  538. owner: string;
  539. name: string;
  540. branch: string;
  541. }
  542. >("GET", (pathParams) => {
  543. return `/api/projects/${pathParams.project_id}/gitrepos/${
  544. pathParams.git_repo_id
  545. }/repos/${pathParams.kind}/${pathParams.owner}/${
  546. pathParams.name
  547. }/${encodeURIComponent(pathParams.branch)}/contents`;
  548. });
  549. const getProcfileContents = baseApi<
  550. {
  551. path: string;
  552. },
  553. {
  554. project_id: number;
  555. git_repo_id: number;
  556. kind: string;
  557. owner: string;
  558. name: string;
  559. branch: string;
  560. }
  561. >("GET", (pathParams) => {
  562. return `/api/projects/${pathParams.project_id}/gitrepos/${
  563. pathParams.git_repo_id
  564. }/repos/${pathParams.kind}/${pathParams.owner}/${
  565. pathParams.name
  566. }/${encodeURIComponent(pathParams.branch)}/procfile`;
  567. });
  568. const getGitlabProcfileContents = baseApi<
  569. {
  570. path: string;
  571. },
  572. {
  573. project_id: number;
  574. integration_id: number;
  575. owner: string;
  576. name: string;
  577. branch: string;
  578. }
  579. >(
  580. "GET",
  581. ({ project_id, integration_id, owner, name, branch }) =>
  582. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${owner}/${name}/${encodeURIComponent(
  583. branch
  584. )}/procfile`
  585. );
  586. const getBranches = baseApi<
  587. {},
  588. {
  589. project_id: number;
  590. git_repo_id: number;
  591. kind: string;
  592. owner: string;
  593. name: string;
  594. }
  595. >("GET", (pathParams) => {
  596. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name}/branches`;
  597. });
  598. const getChart = baseApi<
  599. {},
  600. {
  601. id: number;
  602. cluster_id: number;
  603. namespace: string;
  604. name: string;
  605. revision: number;
  606. }
  607. >("GET", (pathParams) => {
  608. let { id, cluster_id, namespace, name, revision } = pathParams;
  609. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}`;
  610. });
  611. const getCharts = baseApi<
  612. {
  613. limit: number;
  614. skip: number;
  615. byDate: boolean;
  616. statusFilter: string[];
  617. },
  618. {
  619. id: number;
  620. cluster_id: number;
  621. namespace: string;
  622. }
  623. >("GET", (pathParams) => {
  624. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/releases`;
  625. });
  626. const getChartComponents = baseApi<
  627. {},
  628. {
  629. id: number;
  630. cluster_id: number;
  631. namespace: string;
  632. name: string;
  633. revision: number;
  634. }
  635. >("GET", (pathParams) => {
  636. let { id, cluster_id, namespace, name, revision } = pathParams;
  637. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/components`;
  638. });
  639. const getChartControllers = baseApi<
  640. {},
  641. {
  642. id: number;
  643. cluster_id: number;
  644. namespace: string;
  645. name: string;
  646. revision: number;
  647. }
  648. >("GET", (pathParams) => {
  649. let { id, cluster_id, namespace, name, revision } = pathParams;
  650. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/${revision}/controllers`;
  651. });
  652. const getClusterIntegrations = baseApi("GET", "/api/integrations/cluster");
  653. const getClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  654. return `/api/projects/${pathParams.id}/clusters`;
  655. });
  656. const getCluster = baseApi<
  657. {},
  658. {
  659. project_id: number;
  660. cluster_id: number;
  661. }
  662. >("GET", (pathParams) => {
  663. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}`;
  664. });
  665. const getClusterNodes = baseApi<
  666. {},
  667. {
  668. project_id: number;
  669. cluster_id: number;
  670. }
  671. >("GET", (pathParams) => {
  672. return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes`;
  673. });
  674. const getClusterNode = baseApi<
  675. {},
  676. {
  677. project_id: number;
  678. cluster_id: number;
  679. nodeName: string;
  680. }
  681. >(
  682. "GET",
  683. (pathParams) =>
  684. `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/nodes/${pathParams.nodeName}`
  685. );
  686. const getGitRepoList = baseApi<
  687. {},
  688. {
  689. project_id: number;
  690. git_repo_id: number;
  691. }
  692. >("GET", (pathParams) => {
  693. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/repos`;
  694. });
  695. const getGitRepoPermission = baseApi<
  696. {},
  697. {
  698. project_id: number;
  699. git_repo_id: number;
  700. }
  701. >("GET", (pathParams) => {
  702. return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id}/permissions`;
  703. });
  704. const getGitRepos = baseApi<
  705. {},
  706. {
  707. project_id: number;
  708. }
  709. >("GET", (pathParams) => {
  710. return `/api/projects/${pathParams.project_id}/gitrepos`;
  711. });
  712. const getImageRepos = baseApi<
  713. {},
  714. {
  715. project_id: number;
  716. registry_id: number;
  717. }
  718. >("GET", (pathParams) => {
  719. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
  720. });
  721. const getImageTags = baseApi<
  722. {},
  723. {
  724. project_id: number;
  725. registry_id: number;
  726. repo_name: string;
  727. }
  728. >("GET", (pathParams) => {
  729. return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
  730. });
  731. const getInfra = baseApi<
  732. {
  733. version?: string;
  734. },
  735. {
  736. project_id: number;
  737. }
  738. >("GET", (pathParams) => {
  739. return `/api/projects/${pathParams.project_id}/infra`;
  740. });
  741. const listInfraTemplates = baseApi<
  742. {},
  743. {
  744. project_id: number;
  745. }
  746. >("GET", (pathParams) => {
  747. return `/api/projects/${pathParams.project_id}/infras/templates`;
  748. });
  749. const getInfraTemplate = baseApi<
  750. {},
  751. {
  752. project_id: number;
  753. name: string;
  754. version: string;
  755. }
  756. >("GET", (pathParams) => {
  757. let { project_id, name, version } = pathParams;
  758. return `/api/projects/${project_id}/infras/templates/${name}/${version}`;
  759. });
  760. const provisionInfra = baseApi<
  761. {
  762. kind: string;
  763. values: any;
  764. aws_integration_id?: number;
  765. gcp_integration_id?: number;
  766. do_integration_id?: number;
  767. azure_integration_id?: number;
  768. cluster_id?: number;
  769. },
  770. {
  771. project_id: number;
  772. }
  773. >("POST", ({ project_id }) => {
  774. return `/api/projects/${project_id}/infras`;
  775. });
  776. const updateInfra = baseApi<
  777. {
  778. values?: any;
  779. },
  780. {
  781. project_id: number;
  782. infra_id: number;
  783. }
  784. >("POST", (pathParams) => {
  785. let { project_id, infra_id } = pathParams;
  786. return `/api/projects/${project_id}/infras/${infra_id}/update`;
  787. });
  788. const retryCreateInfra = baseApi<
  789. {
  790. aws_integration_id?: number;
  791. gcp_integration_id?: number;
  792. do_integration_id?: number;
  793. values?: any;
  794. },
  795. {
  796. project_id: number;
  797. infra_id: number;
  798. }
  799. >("POST", (pathParams) => {
  800. let { project_id, infra_id } = pathParams;
  801. return `/api/projects/${project_id}/infras/${infra_id}/retry_create`;
  802. });
  803. const retryDeleteInfra = baseApi<
  804. {
  805. values?: any;
  806. },
  807. {
  808. project_id: number;
  809. infra_id: number;
  810. }
  811. >("POST", (pathParams) => {
  812. let { project_id, infra_id } = pathParams;
  813. return `/api/projects/${project_id}/infras/${infra_id}/retry_delete`;
  814. });
  815. const deleteInfra = baseApi<
  816. {},
  817. {
  818. project_id: number;
  819. infra_id: number;
  820. }
  821. >("DELETE", (pathParams) => {
  822. let { project_id, infra_id } = pathParams;
  823. return `/api/projects/${project_id}/infras/${infra_id}`;
  824. });
  825. const listOperations = baseApi<
  826. {},
  827. {
  828. project_id: number;
  829. infra_id: number;
  830. }
  831. >("GET", (pathParams) => {
  832. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/operations`;
  833. });
  834. const getOperation = baseApi<
  835. {},
  836. {
  837. project_id: number;
  838. infra_id: number;
  839. operation_id: string;
  840. }
  841. >("GET", (pathParams) => {
  842. let { project_id, infra_id, operation_id } = pathParams;
  843. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}`;
  844. });
  845. const getOperationLogs = baseApi<
  846. {},
  847. {
  848. project_id: number;
  849. infra_id: number;
  850. operation_id: string;
  851. }
  852. >("GET", (pathParams) => {
  853. let { project_id, infra_id, operation_id } = pathParams;
  854. return `/api/projects/${project_id}/infras/${infra_id}/operations/${operation_id}/logs`;
  855. });
  856. const getInfraState = baseApi<
  857. {},
  858. {
  859. project_id: number;
  860. infra_id: number;
  861. }
  862. >("GET", (pathParams) => {
  863. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/state`;
  864. });
  865. const getInfraRawState = baseApi<
  866. {},
  867. {
  868. project_id: number;
  869. infra_id: number;
  870. }
  871. >("GET", (pathParams) => {
  872. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/raw_state`;
  873. });
  874. const getInfraByID = baseApi<
  875. {},
  876. {
  877. project_id: number;
  878. infra_id: number;
  879. }
  880. >("GET", (pathParams) => {
  881. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  882. });
  883. const getInfraDesired = baseApi<
  884. {},
  885. {
  886. project_id: number;
  887. infra_id: number;
  888. }
  889. >("GET", (pathParams) => {
  890. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/desired`;
  891. });
  892. const getInfraCurrent = baseApi<
  893. {},
  894. {
  895. project_id: number;
  896. infra_id: number;
  897. }
  898. >("GET", (pathParams) => {
  899. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/current`;
  900. });
  901. const getIngress = baseApi<
  902. {},
  903. { namespace: string; cluster_id: number; name: string; id: number }
  904. >("GET", (pathParams) => {
  905. let { id, name, cluster_id, namespace } = pathParams;
  906. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/ingresses/${name}`;
  907. });
  908. const getInvites = baseApi<{}, { id: number }>("GET", (pathParams) => {
  909. return `/api/projects/${pathParams.id}/invites`;
  910. });
  911. const getJobs = baseApi<
  912. {},
  913. { namespace: string; cluster_id: number; release_name: string; id: number }
  914. >("GET", (pathParams) => {
  915. let { id, release_name, cluster_id, namespace } = pathParams;
  916. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs`;
  917. });
  918. const getJobStatus = baseApi<
  919. {},
  920. { namespace: string; cluster_id: number; release_name: string; id: number }
  921. >("GET", (pathParams) => {
  922. let { id, release_name, cluster_id, namespace } = pathParams;
  923. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/jobs/status`;
  924. });
  925. const getJobPods = baseApi<
  926. {},
  927. { name: string; namespace: string; id: number; cluster_id: number }
  928. >("GET", (pathParams) => {
  929. let { id, name, cluster_id, namespace } = pathParams;
  930. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/pods`;
  931. });
  932. const getPodByName = baseApi<
  933. {},
  934. {
  935. project_id: number;
  936. cluster_id: number;
  937. namespace: string;
  938. name: string;
  939. }
  940. >(
  941. "GET",
  942. ({ project_id, cluster_id, namespace, name }) =>
  943. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pods/${name}`
  944. );
  945. const getMatchingPods = baseApi<
  946. {
  947. namespace: string;
  948. selectors: string[];
  949. },
  950. { id: number; cluster_id: number }
  951. >("GET", (pathParams) => {
  952. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/pods`;
  953. });
  954. const getMetrics = baseApi<
  955. {
  956. metric: string;
  957. shouldsum: boolean;
  958. pods?: string[];
  959. kind?: string; // the controller kind
  960. name?: string;
  961. percentile?: number;
  962. namespace: string;
  963. startrange: number;
  964. endrange: number;
  965. resolution: string;
  966. },
  967. {
  968. id: number;
  969. cluster_id: number;
  970. }
  971. >("GET", (pathParams) => {
  972. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/metrics`;
  973. });
  974. const getNamespaces = baseApi<
  975. {},
  976. {
  977. id: number;
  978. cluster_id: number;
  979. }
  980. >("GET", (pathParams) => {
  981. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces`;
  982. });
  983. const getNGINXIngresses = baseApi<
  984. {},
  985. {
  986. id: number;
  987. cluster_id: number;
  988. }
  989. >("GET", (pathParams) => {
  990. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/ingresses`;
  991. });
  992. const getOAuthIds = baseApi<
  993. {},
  994. {
  995. project_id: number;
  996. }
  997. >("GET", (pathParams) => {
  998. return `/api/projects/${pathParams.project_id}/integrations/oauth`;
  999. });
  1000. const getProjectClusters = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1001. return `/api/projects/${pathParams.id}/clusters`;
  1002. });
  1003. const getProjectRegistries = baseApi<{}, { id: number }>(
  1004. "GET",
  1005. (pathParams) => {
  1006. return `/api/projects/${pathParams.id}/registries`;
  1007. }
  1008. );
  1009. const getProjectRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1010. return `/api/projects/${pathParams.id}/repos`;
  1011. });
  1012. const getProjects = baseApi("GET", "/api/projects");
  1013. const getPrometheusIsInstalled = baseApi<
  1014. {},
  1015. {
  1016. id: number;
  1017. cluster_id: number;
  1018. }
  1019. >("GET", (pathParams) => {
  1020. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/prometheus/detect`;
  1021. });
  1022. const getRegistryIntegrations = baseApi("GET", "/api/integrations/registry");
  1023. const getReleaseToken = baseApi<
  1024. {},
  1025. { name: string; id: number; namespace: string; cluster_id: number }
  1026. >("GET", (pathParams) => {
  1027. let { id, cluster_id, namespace, name } = pathParams;
  1028. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/webhook`;
  1029. });
  1030. const getReleaseSteps = baseApi<
  1031. {},
  1032. { name: string; id: number; namespace: string; cluster_id: number }
  1033. >("GET", (pathParams) => {
  1034. let { id, cluster_id, namespace, name } = pathParams;
  1035. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/steps`;
  1036. });
  1037. const destroyInfra = baseApi<
  1038. {},
  1039. {
  1040. project_id: number;
  1041. infra_id: number;
  1042. }
  1043. >("DELETE", (pathParams) => {
  1044. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}`;
  1045. });
  1046. const updateDatabaseStatus = baseApi<
  1047. {
  1048. status: string;
  1049. },
  1050. {
  1051. project_id: number;
  1052. infra_id: number;
  1053. }
  1054. >("POST", (pathParams) => {
  1055. return `/api/projects/${pathParams.project_id}/infras/${pathParams.infra_id}/database`;
  1056. });
  1057. const getRepoIntegrations = baseApi("GET", "/api/integrations/repo");
  1058. const getRepos = baseApi<{}, { id: number }>("GET", (pathParams) => {
  1059. return `/api/projects/${pathParams.id}/repos`;
  1060. });
  1061. const getSlackIntegrations = baseApi<{}, { id: number }>(
  1062. "GET",
  1063. (pathParams) => {
  1064. return `/api/projects/${pathParams.id}/slack_integrations`;
  1065. }
  1066. );
  1067. const getRevisions = baseApi<
  1068. {},
  1069. { id: number; cluster_id: number; namespace: string; name: string }
  1070. >("GET", (pathParams) => {
  1071. let { id, cluster_id, namespace, name } = pathParams;
  1072. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/history`;
  1073. });
  1074. const getTemplateInfo = baseApi<
  1075. {
  1076. repo_url?: string;
  1077. },
  1078. { name: string; version: string }
  1079. >("GET", (pathParams) => {
  1080. return `/api/templates/${pathParams.name}/${pathParams.version}`;
  1081. });
  1082. const getTemplateUpgradeNotes = baseApi<
  1083. {
  1084. repo_url?: string;
  1085. prev_version: string;
  1086. },
  1087. { name: string; version: string }
  1088. >("GET", (pathParams) => {
  1089. return `/api/templates/${pathParams.name}/${pathParams.version}/upgrade_notes`;
  1090. });
  1091. const getTemplates = baseApi<
  1092. {
  1093. repo_url?: string;
  1094. },
  1095. {}
  1096. >("GET", "/api/templates");
  1097. const getHelmRepos = baseApi<
  1098. {},
  1099. {
  1100. project_id: number;
  1101. }
  1102. >("GET", (pathParams) => {
  1103. return `/api/projects/${pathParams.project_id}/helmrepos`;
  1104. });
  1105. const getChartsFromHelmRepo = baseApi<
  1106. {},
  1107. {
  1108. project_id: number;
  1109. helm_repo_id: number;
  1110. }
  1111. >("GET", (pathParams) => {
  1112. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts`;
  1113. });
  1114. const getChartInfoFromHelmRepo = baseApi<
  1115. {},
  1116. { project_id: number; helm_repo_id: number; name: string; version: string }
  1117. >("GET", (pathParams) => {
  1118. return `/api/projects/${pathParams.project_id}/helmrepos/${pathParams.helm_repo_id}/charts/${pathParams.name}/${pathParams.version}`;
  1119. });
  1120. const getMetadata = baseApi<{}, {}>("GET", () => {
  1121. return `/api/metadata`;
  1122. });
  1123. const postWelcome = baseApi<{
  1124. email: string;
  1125. isCompany: boolean;
  1126. name: string;
  1127. company: string;
  1128. role: string;
  1129. }>("POST", () => {
  1130. return `/api/welcome`;
  1131. });
  1132. const linkGithubProject = baseApi<
  1133. {},
  1134. {
  1135. project_id: number;
  1136. }
  1137. >("GET", (pathParams) => {
  1138. return `/api/oauth/projects/${pathParams.project_id}/github`;
  1139. });
  1140. const getGithubAccounts = baseApi<{}, {}>("GET", () => {
  1141. return `/api/integrations/github-app/accounts`;
  1142. });
  1143. const logInUser = baseApi<{
  1144. email: string;
  1145. password: string;
  1146. }>("POST", "/api/login");
  1147. const logOutUser = baseApi("POST", "/api/logout");
  1148. const registerUser = baseApi<{
  1149. email: string;
  1150. password: string;
  1151. }>("POST", "/api/users");
  1152. const rollbackChart = baseApi<
  1153. {
  1154. revision: number;
  1155. },
  1156. {
  1157. id: number;
  1158. name: string;
  1159. namespace: string;
  1160. cluster_id: number;
  1161. }
  1162. >("POST", (pathParams) => {
  1163. let { id, name, cluster_id, namespace } = pathParams;
  1164. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/rollback`;
  1165. });
  1166. const uninstallTemplate = baseApi<
  1167. {},
  1168. {
  1169. id: number;
  1170. name: string;
  1171. cluster_id: number;
  1172. namespace: string;
  1173. }
  1174. >("DELETE", (pathParams) => {
  1175. let { id, name, cluster_id, namespace } = pathParams;
  1176. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0`;
  1177. });
  1178. const updateUser = baseApi<
  1179. {
  1180. rawKubeConfig?: string;
  1181. allowedContexts?: string[];
  1182. },
  1183. { id: number }
  1184. >("PUT", (pathParams) => {
  1185. return `/api/users/${pathParams.id}`;
  1186. });
  1187. const upgradeChartValues = baseApi<
  1188. {
  1189. values: string;
  1190. version?: string;
  1191. latest_revision?: number;
  1192. },
  1193. {
  1194. id: number;
  1195. name: string;
  1196. namespace: string;
  1197. cluster_id: number;
  1198. }
  1199. >("POST", (pathParams) => {
  1200. let { id, name, cluster_id, namespace } = pathParams;
  1201. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${name}/0/upgrade`;
  1202. });
  1203. const listEnvGroups = baseApi<
  1204. {},
  1205. {
  1206. id: number;
  1207. namespace: string;
  1208. cluster_id: number;
  1209. }
  1210. >("GET", (pathParams) => {
  1211. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/list`;
  1212. });
  1213. const listConfigMaps = baseApi<
  1214. {},
  1215. {
  1216. id: number;
  1217. namespace: string;
  1218. cluster_id: number;
  1219. }
  1220. >("GET", (pathParams) => {
  1221. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/list`;
  1222. });
  1223. const getEnvGroup = baseApi<
  1224. {},
  1225. {
  1226. id: number;
  1227. namespace: string;
  1228. cluster_id: number;
  1229. name: string;
  1230. version?: number;
  1231. }
  1232. >("GET", (pathParams) => {
  1233. return `/api/projects/${pathParams.id}/clusters/${
  1234. pathParams.cluster_id
  1235. }/namespaces/${pathParams.namespace}/envgroup?name=${pathParams.name}${
  1236. pathParams.version ? "&version=" + pathParams.version : ""
  1237. }`;
  1238. });
  1239. const getConfigMap = baseApi<
  1240. {
  1241. name: string;
  1242. },
  1243. {
  1244. id: number;
  1245. namespace: string;
  1246. cluster_id: number;
  1247. }
  1248. >("GET", (pathParams) => {
  1249. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap`;
  1250. });
  1251. const createEnvGroup = baseApi<
  1252. {
  1253. name: string;
  1254. variables: Record<string, string>;
  1255. secret_variables?: Record<string, string>;
  1256. },
  1257. {
  1258. id: number;
  1259. cluster_id: number;
  1260. namespace: string;
  1261. }
  1262. >("POST", (pathParams) => {
  1263. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup/create`;
  1264. });
  1265. const updateEnvGroup = baseApi<
  1266. {
  1267. name: string;
  1268. variables: { [key: string]: string };
  1269. secret_variables?: { [key: string]: string };
  1270. },
  1271. {
  1272. project_id: number;
  1273. cluster_id: number;
  1274. namespace: string;
  1275. }
  1276. >(
  1277. "POST",
  1278. ({ cluster_id, project_id, namespace }) =>
  1279. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/create`
  1280. );
  1281. const createConfigMap = baseApi<
  1282. {
  1283. name: string;
  1284. variables: Record<string, string>;
  1285. secret_variables?: Record<string, string>;
  1286. },
  1287. {
  1288. id: number;
  1289. cluster_id: number;
  1290. namespace: string;
  1291. }
  1292. >("POST", (pathParams) => {
  1293. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/create`;
  1294. });
  1295. const updateConfigMap = baseApi<
  1296. {
  1297. name: string;
  1298. variables: Record<string, string>;
  1299. secret_variables?: Record<string, string>;
  1300. },
  1301. {
  1302. id: number;
  1303. cluster_id: number;
  1304. namespace: string;
  1305. }
  1306. >("POST", (pathParams) => {
  1307. let { id, cluster_id } = pathParams;
  1308. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/update`;
  1309. });
  1310. const renameConfigMap = baseApi<
  1311. {
  1312. name: string;
  1313. new_name: string;
  1314. },
  1315. {
  1316. id: number;
  1317. cluster_id: number;
  1318. namespace: string;
  1319. }
  1320. >("POST", (pathParams) => {
  1321. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/rename`;
  1322. });
  1323. const deleteEnvGroup = baseApi<
  1324. {
  1325. name: string;
  1326. },
  1327. {
  1328. id: number;
  1329. namespace: string;
  1330. cluster_id: number;
  1331. }
  1332. >("DELETE", (pathParams) => {
  1333. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/envgroup`;
  1334. });
  1335. const deleteConfigMap = baseApi<
  1336. {
  1337. name: string;
  1338. },
  1339. {
  1340. id: number;
  1341. namespace: string;
  1342. cluster_id: number;
  1343. }
  1344. >("DELETE", (pathParams) => {
  1345. return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id}/namespaces/${pathParams.namespace}/configmap/delete`;
  1346. });
  1347. const createNamespace = baseApi<
  1348. {
  1349. name: string;
  1350. },
  1351. { id: number; cluster_id: number }
  1352. >("POST", (pathParams) => {
  1353. let { id, cluster_id } = pathParams;
  1354. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/create`;
  1355. });
  1356. const deleteNamespace = baseApi<
  1357. {},
  1358. {
  1359. id: number;
  1360. cluster_id: number;
  1361. namespace: string;
  1362. }
  1363. >("DELETE", (pathParams) => {
  1364. let { id, cluster_id, namespace } = pathParams;
  1365. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}`;
  1366. });
  1367. const deleteJob = baseApi<
  1368. {},
  1369. { name: string; namespace: string; id: number; cluster_id: number }
  1370. >("DELETE", (pathParams) => {
  1371. let { id, name, cluster_id, namespace } = pathParams;
  1372. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}`;
  1373. });
  1374. const stopJob = baseApi<
  1375. {},
  1376. { name: string; namespace: string; id: number; cluster_id: number }
  1377. >("POST", (pathParams) => {
  1378. let { id, name, namespace, cluster_id } = pathParams;
  1379. return `/api/projects/${id}/clusters/${cluster_id}/namespaces/${namespace}/jobs/${name}/stop`;
  1380. });
  1381. const listAPITokens = baseApi<{}, { project_id: number }>(
  1382. "GET",
  1383. ({ project_id }) => `/api/projects/${project_id}/api_token`
  1384. );
  1385. const getAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1386. "GET",
  1387. ({ project_id, token }) => `/api/projects/${project_id}/api_token/${token}`
  1388. );
  1389. const revokeAPIToken = baseApi<{}, { project_id: number; token: string }>(
  1390. "POST",
  1391. ({ project_id, token }) =>
  1392. `/api/projects/${project_id}/api_token/${token}/revoke`
  1393. );
  1394. const createAPIToken = baseApi<
  1395. {
  1396. name: string;
  1397. policy_uid: string;
  1398. expires_at?: string;
  1399. },
  1400. { project_id: number }
  1401. >("POST", ({ project_id }) => `/api/projects/${project_id}/api_token`);
  1402. const createPolicy = baseApi<
  1403. {
  1404. name: string;
  1405. policy: PolicyDocType[];
  1406. },
  1407. { project_id: number }
  1408. >("POST", ({ project_id }) => `/api/projects/${project_id}/policy`);
  1409. const getAvailableRoles = baseApi<{}, { project_id: number }>(
  1410. "GET",
  1411. ({ project_id }) => `/api/projects/${project_id}/roles`
  1412. );
  1413. const updateInvite = baseApi<
  1414. { kind: string; roles: string[] },
  1415. { project_id: number; invite_id: number }
  1416. >(
  1417. "PATCH",
  1418. ({ project_id, invite_id }) =>
  1419. `/api/projects/${project_id}/invites/${invite_id}`
  1420. );
  1421. const getCollaborators = baseApi<{}, { project_id: number }>(
  1422. "GET",
  1423. ({ project_id }) => `/api/projects/${project_id}/collaborators`
  1424. );
  1425. const updateCollaborator = baseApi<
  1426. {
  1427. roles: string[];
  1428. },
  1429. {
  1430. project_id: number;
  1431. user_id: number;
  1432. }
  1433. >(
  1434. "PATCH",
  1435. ({ project_id, user_id }) =>
  1436. `/api/projects/${project_id}/collaborators/${user_id}`
  1437. );
  1438. const removeCollaborator = baseApi<
  1439. {},
  1440. {
  1441. project_id: number;
  1442. user_id: number;
  1443. }
  1444. >(
  1445. "DELETE",
  1446. ({ project_id, user_id }) =>
  1447. `/api/projects/${project_id}/collaborators/${user_id}`
  1448. );
  1449. const getPolicyDocument = baseApi<{}, { project_id: number }>(
  1450. "GET",
  1451. ({ project_id }) => `/api/projects/${project_id}/policy`
  1452. );
  1453. const createWebhookToken = baseApi<
  1454. {},
  1455. {
  1456. project_id: number;
  1457. chart_name: string;
  1458. namespace: string;
  1459. cluster_id: number;
  1460. }
  1461. >(
  1462. "POST",
  1463. ({ project_id, chart_name, namespace, cluster_id }) =>
  1464. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${chart_name}/0/webhook`
  1465. );
  1466. const getUsage = baseApi<{}, { project_id: number }>(
  1467. "GET",
  1468. ({ project_id }) => `/api/projects/${project_id}/usage`
  1469. );
  1470. // Used for billing purposes
  1471. const getCustomerToken = baseApi<{}, { project_id: number }>(
  1472. "GET",
  1473. ({ project_id }) => `/api/projects/${project_id}/billing/token`
  1474. );
  1475. const getHasBilling = baseApi<{}, { project_id: number }>(
  1476. "GET",
  1477. ({ project_id }) => `/api/projects/${project_id}/billing`
  1478. );
  1479. const getOnboardingState = baseApi<{}, { project_id: number }>(
  1480. "GET",
  1481. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1482. );
  1483. const saveOnboardingState = baseApi<{}, { project_id: number }>(
  1484. "POST",
  1485. ({ project_id }) => `/api/projects/${project_id}/onboarding`
  1486. );
  1487. const getOnboardingInfra = baseApi<
  1488. {},
  1489. { project_id: number; registry_infra_id: number }
  1490. >(
  1491. "GET",
  1492. ({ project_id, registry_infra_id }) =>
  1493. `/api/projects/${project_id}/infras/${registry_infra_id}`
  1494. );
  1495. const getOnboardingRegistry = baseApi<
  1496. {},
  1497. { project_id: number; registry_connection_id: number }
  1498. >(
  1499. "GET",
  1500. ({ project_id, registry_connection_id }) =>
  1501. `/api/projects/${project_id}/registries/${registry_connection_id}`
  1502. );
  1503. const detectPorterAgent = baseApi<
  1504. {},
  1505. { project_id: number; cluster_id: number }
  1506. >(
  1507. "GET",
  1508. ({ project_id, cluster_id }) =>
  1509. `/api/projects/${project_id}/clusters/${cluster_id}/agent/detect`
  1510. );
  1511. const installPorterAgent = baseApi<
  1512. {},
  1513. { project_id: number; cluster_id: number }
  1514. >(
  1515. "POST",
  1516. ({ cluster_id, project_id }) =>
  1517. `/api/projects/${project_id}/clusters/${cluster_id}/agent/install`
  1518. );
  1519. const getKubeEvents = baseApi<
  1520. {
  1521. skip: number;
  1522. resource_type: string;
  1523. owner_type?: string;
  1524. owner_name?: string;
  1525. namespace?: string;
  1526. },
  1527. { project_id: number; cluster_id: number }
  1528. >("GET", ({ project_id, cluster_id }) => {
  1529. return `/api/projects/${project_id}/clusters/${cluster_id}/kube_events`;
  1530. });
  1531. const getKubeEvent = baseApi<
  1532. {},
  1533. { project_id: number; cluster_id: number; kube_event_id: number }
  1534. >(
  1535. "GET",
  1536. ({ project_id, cluster_id, kube_event_id }) =>
  1537. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}`
  1538. );
  1539. const getLogBuckets = baseApi<
  1540. {},
  1541. { project_id: number; cluster_id: number; kube_event_id: number }
  1542. >(
  1543. "GET",
  1544. ({ project_id, cluster_id, kube_event_id }) =>
  1545. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/log_buckets`
  1546. );
  1547. const getLogBucketLogs = baseApi<
  1548. { timestamp: number },
  1549. { project_id: number; cluster_id: number; kube_event_id: number }
  1550. >(
  1551. "GET",
  1552. ({ project_id, cluster_id, kube_event_id }) =>
  1553. `/api/projects/${project_id}/clusters/${cluster_id}/kube_events/${kube_event_id}/logs`
  1554. );
  1555. const getCanCreateProject = baseApi<{}, {}>(
  1556. "GET",
  1557. () => "/api/can_create_project"
  1558. );
  1559. const addApplicationToEnvGroup = baseApi<
  1560. {
  1561. name: string; // Env Group name
  1562. app_name: string;
  1563. },
  1564. { project_id: number; cluster_id: number; namespace: string }
  1565. >(
  1566. "POST",
  1567. ({ cluster_id, namespace, project_id }) =>
  1568. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/add_application`
  1569. );
  1570. const removeApplicationFromEnvGroup = baseApi<
  1571. {
  1572. name: string; // Env Group name
  1573. app_name: string;
  1574. },
  1575. { project_id: number; cluster_id: number; namespace: string }
  1576. >(
  1577. "POST",
  1578. ({ cluster_id, namespace, project_id }) =>
  1579. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/envgroup/remove_application`
  1580. );
  1581. const provisionDatabase = baseApi<
  1582. {
  1583. username: string;
  1584. password: string;
  1585. machine_type: string;
  1586. db_storage_encrypted: boolean;
  1587. db_name: string;
  1588. db_max_allocated_storage: string;
  1589. db_family: string;
  1590. db_engine_version: string;
  1591. db_allocated_storage: string;
  1592. },
  1593. { project_id: number; cluster_id: number; namespace: string }
  1594. >(
  1595. "POST",
  1596. ({ project_id, cluster_id, namespace }) =>
  1597. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/provision/rds`
  1598. );
  1599. const getDatabases = baseApi<
  1600. {},
  1601. {
  1602. project_id: number;
  1603. cluster_id: number;
  1604. }
  1605. >(
  1606. "GET",
  1607. ({ project_id, cluster_id }) =>
  1608. `/api/projects/${project_id}/clusters/${cluster_id}/databases`
  1609. );
  1610. const getPreviousLogsForContainer = baseApi<
  1611. {
  1612. container_name: string;
  1613. },
  1614. {
  1615. project_id: number;
  1616. cluster_id: number;
  1617. namespace: string;
  1618. pod_name: string;
  1619. }
  1620. >(
  1621. "GET",
  1622. ({ cluster_id, namespace, pod_name: name, project_id }) =>
  1623. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/pod/${name}/previous_logs`
  1624. );
  1625. const getIncidents = baseApi<
  1626. {},
  1627. {
  1628. project_id: number;
  1629. cluster_id: number;
  1630. }
  1631. >(
  1632. "GET",
  1633. ({ project_id, cluster_id }) =>
  1634. `/api/projects/${project_id}/clusters/${cluster_id}/incidents`
  1635. );
  1636. const getIncidentsByReleaseName = baseApi<
  1637. {
  1638. namespace: string;
  1639. release_name: string;
  1640. },
  1641. {
  1642. project_id: number;
  1643. cluster_id: number;
  1644. }
  1645. >(
  1646. "GET",
  1647. ({ project_id, cluster_id }) =>
  1648. `/api/projects/${project_id}/clusters/${cluster_id}/incidents`
  1649. );
  1650. const getIncidentById = baseApi<
  1651. {
  1652. incident_id: string;
  1653. },
  1654. {
  1655. project_id: number;
  1656. cluster_id: number;
  1657. }
  1658. >(
  1659. "GET",
  1660. ({ project_id, cluster_id }) =>
  1661. `/api/projects/${project_id}/clusters/${cluster_id}/incidents`
  1662. );
  1663. const getIncidentLogsByLogId = baseApi<
  1664. {
  1665. log_id: string;
  1666. },
  1667. {
  1668. project_id: number;
  1669. cluster_id: number;
  1670. }
  1671. >(
  1672. "GET",
  1673. ({ project_id, cluster_id }) =>
  1674. `/api/projects/${project_id}/clusters/${cluster_id}/incidents/logs`
  1675. );
  1676. const upgradePorterAgent = baseApi<
  1677. {},
  1678. { project_id: number; cluster_id: number }
  1679. >(
  1680. "POST",
  1681. ({ project_id, cluster_id }) =>
  1682. `/api/projects/${project_id}/clusters/${cluster_id}/agent/upgrade`
  1683. );
  1684. const updateBuildConfig = baseApi<
  1685. BuildConfig,
  1686. {
  1687. project_id: number;
  1688. cluster_id: number;
  1689. namespace: string;
  1690. release_name: string;
  1691. }
  1692. >(
  1693. "POST",
  1694. ({ project_id, cluster_id, namespace, release_name }) =>
  1695. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/buildconfig`
  1696. );
  1697. const updateGitActionConfig = baseApi<
  1698. {
  1699. git_action_config: {
  1700. git_branch: string;
  1701. };
  1702. },
  1703. {
  1704. project_id: number;
  1705. cluster_id: number;
  1706. namespace: string;
  1707. release_name: string;
  1708. revision?: 0; // Always update latest
  1709. }
  1710. >(
  1711. "PATCH",
  1712. ({ project_id, cluster_id, namespace, release_name, revision = 0 }) =>
  1713. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/${revision}/git_action_config`
  1714. );
  1715. const reRunGHWorkflow = baseApi<
  1716. {},
  1717. {
  1718. project_id: number;
  1719. cluster_id: number;
  1720. git_installation_id: number;
  1721. owner: string;
  1722. name: string;
  1723. branch?: string;
  1724. filename?: string;
  1725. release_name?: string;
  1726. }
  1727. >(
  1728. "POST",
  1729. ({
  1730. project_id,
  1731. git_installation_id,
  1732. owner,
  1733. name,
  1734. cluster_id,
  1735. filename,
  1736. release_name,
  1737. branch,
  1738. }) => {
  1739. const queryParams = new URLSearchParams();
  1740. if (branch) {
  1741. queryParams.set("branch", branch);
  1742. }
  1743. if (release_name) {
  1744. queryParams.set("release_name", release_name);
  1745. }
  1746. if (filename) {
  1747. queryParams.set("filename", filename);
  1748. }
  1749. return `/api/projects/${project_id}/gitrepos/${git_installation_id}/${owner}/${name}/clusters/${cluster_id}/rerun_workflow?${queryParams.toString()}`;
  1750. }
  1751. );
  1752. const triggerPreviewEnvWorkflow = baseApi<
  1753. {},
  1754. { project_id: number; cluster_id: number; deployment_id: number }
  1755. >(
  1756. "POST",
  1757. ({ project_id, cluster_id, deployment_id }) =>
  1758. `/api/projects/${project_id}/clusters/${cluster_id}/deployments/${deployment_id}/trigger_workflow`
  1759. );
  1760. const getTagsByProjectId = baseApi<{}, { project_id: number }>(
  1761. "GET",
  1762. ({ project_id }) => `/api/projects/${project_id}/tags`
  1763. );
  1764. const createTag = baseApi<
  1765. { name: string; color: string },
  1766. { project_id: number }
  1767. >("POST", ({ project_id }) => `/api/projects/${project_id}/tags`);
  1768. const updateReleaseTags = baseApi<
  1769. {
  1770. tags: string[];
  1771. },
  1772. {
  1773. project_id: number;
  1774. cluster_id: number;
  1775. namespace: string;
  1776. release_name: string;
  1777. }
  1778. >(
  1779. "PATCH",
  1780. ({ project_id, cluster_id, namespace, release_name }) =>
  1781. `/api/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/releases/${release_name}/0/update_tags`
  1782. );
  1783. const getGitProviders = baseApi<{}, { project_id: number }>(
  1784. "GET",
  1785. ({ project_id }) => `/api/projects/${project_id}/integrations/git`
  1786. );
  1787. const getGitlabRepos = baseApi<
  1788. {},
  1789. { project_id: number; integration_id: number }
  1790. >(
  1791. "GET",
  1792. ({ project_id, integration_id }) =>
  1793. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos`
  1794. );
  1795. const getGitlabBranches = baseApi<
  1796. {},
  1797. {
  1798. project_id: number;
  1799. integration_id: number;
  1800. repo_owner: string;
  1801. repo_name: string;
  1802. }
  1803. >(
  1804. "GET",
  1805. ({ project_id, integration_id, repo_owner, repo_name }) =>
  1806. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/branches`
  1807. );
  1808. const getGitlabFolderContent = baseApi<
  1809. {
  1810. dir: string;
  1811. },
  1812. {
  1813. project_id: number;
  1814. integration_id: number;
  1815. repo_owner: string;
  1816. repo_name: string;
  1817. branch: string;
  1818. }
  1819. >(
  1820. "GET",
  1821. ({ project_id, integration_id, repo_owner, repo_name, branch }) =>
  1822. `/api/projects/${project_id}/integrations/gitlab/${integration_id}/repos/${repo_owner}/${repo_name}/${branch}/contents`
  1823. );
  1824. // STACKS
  1825. const createStack = baseApi<
  1826. CreateStackBody,
  1827. {
  1828. project_id: number;
  1829. cluster_id: number;
  1830. namespace: string;
  1831. }
  1832. >(
  1833. "POST",
  1834. ({ project_id, cluster_id, namespace }) =>
  1835. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  1836. );
  1837. const updateStack = baseApi<
  1838. {
  1839. name: string;
  1840. },
  1841. {
  1842. project_id: number;
  1843. cluster_id: number;
  1844. namespace: string;
  1845. stack_id: string;
  1846. }
  1847. >(
  1848. "PATCH",
  1849. ({ project_id, cluster_id, namespace, stack_id }) =>
  1850. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1851. );
  1852. const listStacks = baseApi<
  1853. {},
  1854. { project_id: number; cluster_id: number; namespace: string }
  1855. >(
  1856. "GET",
  1857. ({ project_id, cluster_id, namespace }) =>
  1858. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks`
  1859. );
  1860. const getStack = baseApi<
  1861. {},
  1862. {
  1863. project_id: number;
  1864. cluster_id: number;
  1865. namespace: string;
  1866. stack_id: string;
  1867. }
  1868. >(
  1869. "GET",
  1870. ({ project_id, cluster_id, namespace, stack_id }) =>
  1871. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1872. );
  1873. const getStackRevision = baseApi<
  1874. {},
  1875. {
  1876. project_id: number;
  1877. cluster_id: number;
  1878. namespace: string;
  1879. stack_id: string;
  1880. revision_id: number;
  1881. }
  1882. >(
  1883. "GET",
  1884. ({ project_id, cluster_id, namespace, stack_id, revision_id }) =>
  1885. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/${revision_id}`
  1886. );
  1887. const rollbackStack = baseApi<
  1888. {
  1889. target_revision: number;
  1890. },
  1891. {
  1892. project_id: number;
  1893. cluster_id: number;
  1894. namespace: string;
  1895. stack_id: string;
  1896. }
  1897. >(
  1898. "POST",
  1899. ({ project_id, cluster_id, namespace, stack_id }) =>
  1900. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/rollback`
  1901. );
  1902. const deleteStack = baseApi<
  1903. {},
  1904. {
  1905. project_id: number;
  1906. cluster_id: number;
  1907. namespace: string;
  1908. stack_id: string;
  1909. }
  1910. >(
  1911. "DELETE",
  1912. ({ project_id, cluster_id, namespace, stack_id }) =>
  1913. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}`
  1914. );
  1915. const updateStackSourceConfig = baseApi<
  1916. {
  1917. source_configs: SourceConfig[];
  1918. },
  1919. {
  1920. project_id: number;
  1921. cluster_id: number;
  1922. namespace: string;
  1923. stack_id: string;
  1924. }
  1925. >(
  1926. "PUT",
  1927. ({ project_id, cluster_id, namespace, stack_id }) =>
  1928. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/source`
  1929. );
  1930. const addStackAppResource = baseApi<
  1931. CreateStackBody["app_resources"][0],
  1932. {
  1933. project_id: number;
  1934. cluster_id: number;
  1935. namespace: string;
  1936. stack_id: string;
  1937. }
  1938. >(
  1939. "PATCH",
  1940. ({ project_id, cluster_id, namespace, stack_id }) =>
  1941. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_application`
  1942. );
  1943. const removeStackAppResource = baseApi<
  1944. {},
  1945. {
  1946. project_id: number;
  1947. cluster_id: number;
  1948. namespace: string;
  1949. stack_id: string;
  1950. app_resource_name: string;
  1951. }
  1952. >(
  1953. "DELETE",
  1954. ({ project_id, cluster_id, namespace, stack_id, app_resource_name }) =>
  1955. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_application/${app_resource_name}`
  1956. );
  1957. const addStackEnvGroup = baseApi<
  1958. CreateStackBody["env_groups"][0],
  1959. {
  1960. project_id: number;
  1961. cluster_id: number;
  1962. namespace: string;
  1963. stack_id: string;
  1964. }
  1965. >(
  1966. "PATCH",
  1967. ({ project_id, cluster_id, namespace, stack_id }) =>
  1968. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/add_env_group`
  1969. );
  1970. const removeStackEnvGroup = baseApi<
  1971. {},
  1972. {
  1973. project_id: number;
  1974. cluster_id: number;
  1975. namespace: string;
  1976. stack_id: string;
  1977. env_group_name: string;
  1978. }
  1979. >(
  1980. "DELETE",
  1981. ({ project_id, cluster_id, namespace, stack_id, env_group_name }) =>
  1982. `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_env_group/${env_group_name}`
  1983. );
  1984. const getGithubStatus = baseApi<{}, {}>("GET", ({}) => `/api/status/github`);
  1985. // ROLES
  1986. /**
  1987. POST /api/projects/{project_id}/project_roles
  1988. GET /api/projects/{project_id}/project_roles/{role_id}
  1989. GET /api/projects/{project_id}/project_roles
  1990. PATCH /api/projects/{project_id}/project_roles/{role_id}
  1991. DELETE /api/projects/{project_id}/project_roles/{role_id}
  1992. PATCH /api/projects/{project_id}/invites/{invite_id}
  1993. POST /api/projects/{project_id}/invites
  1994. */
  1995. const listRoles = baseApi<{}, { project_id: number }>(
  1996. "GET",
  1997. ({ project_id }) => `/api/projects/${project_id}/project_roles`
  1998. );
  1999. const createRole = baseApi<
  2000. CreateRoleBody,
  2001. {
  2002. project_id: number;
  2003. }
  2004. >("POST", ({ project_id }) => `/api/projects/${project_id}/project_roles`);
  2005. const getRole = baseApi<
  2006. {},
  2007. {
  2008. project_id: number;
  2009. role_id: string;
  2010. }
  2011. >(
  2012. "GET",
  2013. ({ project_id, role_id }) =>
  2014. `/api/projects/${project_id}/project_roles/${role_id}`
  2015. );
  2016. const updateRole = baseApi<
  2017. UpdateRoleBody,
  2018. {
  2019. project_id: number;
  2020. role_id: string;
  2021. }
  2022. >(
  2023. "PATCH",
  2024. ({ project_id, role_id }) =>
  2025. `/api/projects/${project_id}/project_roles/${role_id}`
  2026. );
  2027. const deleteRole = baseApi<
  2028. {},
  2029. {
  2030. project_id: number;
  2031. role_id: string;
  2032. }
  2033. >(
  2034. "DELETE",
  2035. ({ project_id, role_id }) =>
  2036. `/api/projects/${project_id}/project_roles/${role_id}`
  2037. );
  2038. const getScopeHierarchy = baseApi<
  2039. {},
  2040. {
  2041. project_id: number;
  2042. }
  2043. >(
  2044. "GET",
  2045. ({ project_id }) =>
  2046. `/api/projects/${project_id}/project_roles/scope_hierarchy`
  2047. );
  2048. // /ROLES
  2049. // Bundle export to allow default api import (api.<method> is more readable)
  2050. export default {
  2051. checkAuth,
  2052. connectECRRegistry,
  2053. connectGCRRegistry,
  2054. connectDORegistry,
  2055. getAWSIntegration,
  2056. getGCPIntegration,
  2057. getAzureIntegration,
  2058. getGitlabIntegration,
  2059. createAWSIntegration,
  2060. overwriteAWSIntegration,
  2061. updateClusterName,
  2062. createAzureIntegration,
  2063. createGitlabIntegration,
  2064. createEmailVerification,
  2065. createEnvironment,
  2066. updateEnvironment,
  2067. deleteEnvironment,
  2068. createPreviewEnvironmentDeployment,
  2069. reenablePreviewEnvironmentDeployment,
  2070. listEnvironments,
  2071. getEnvironment,
  2072. toggleNewCommentForEnvironment,
  2073. createGCPIntegration,
  2074. createInvite,
  2075. createNamespace,
  2076. createPasswordReset,
  2077. createPasswordResetVerify,
  2078. createPasswordResetFinalize,
  2079. createProject,
  2080. createConfigMap,
  2081. deleteCluster,
  2082. deleteConfigMap,
  2083. deleteInvite,
  2084. deleteNamespace,
  2085. deletePod,
  2086. deleteProject,
  2087. deleteRegistryIntegration,
  2088. deleteSlackIntegration,
  2089. updateNotificationConfig,
  2090. getNotificationConfig,
  2091. createSubdomain,
  2092. deployTemplate,
  2093. deployAddon,
  2094. destroyInfra,
  2095. updateDatabaseStatus,
  2096. detectBuildpack,
  2097. detectGitlabBuildpack,
  2098. getBranchContents,
  2099. getBranches,
  2100. getMetadata,
  2101. postWelcome,
  2102. getChart,
  2103. getCharts,
  2104. getChartComponents,
  2105. getChartControllers,
  2106. getClusterIntegrations,
  2107. getClusters,
  2108. getCluster,
  2109. getClusterNodes,
  2110. getClusterNode,
  2111. getConfigMap,
  2112. getPRDeploymentList,
  2113. getPRDeploymentByEnvironment,
  2114. getPRDeployment,
  2115. getGHAWorkflowTemplate,
  2116. getGitRepoList,
  2117. getGitRepoPermission,
  2118. getGitRepos,
  2119. getImageRepos,
  2120. getImageTags,
  2121. listInfraTemplates,
  2122. getInfraTemplate,
  2123. getInfra,
  2124. provisionInfra,
  2125. deleteInfra,
  2126. updateInfra,
  2127. listOperations,
  2128. getOperation,
  2129. getOperationLogs,
  2130. retryCreateInfra,
  2131. retryDeleteInfra,
  2132. getInfraState,
  2133. getInfraRawState,
  2134. getInfraByID,
  2135. getInfraDesired,
  2136. getInfraCurrent,
  2137. getIngress,
  2138. getInvites,
  2139. getJobs,
  2140. getJobStatus,
  2141. getJobPods,
  2142. getPodByName,
  2143. getMatchingPods,
  2144. getMetrics,
  2145. getNamespaces,
  2146. getNGINXIngresses,
  2147. getOAuthIds,
  2148. getPodEvents,
  2149. getProcfileContents,
  2150. getGitlabProcfileContents,
  2151. getProjectClusters,
  2152. getProjectRegistries,
  2153. getProjectRepos,
  2154. getProjects,
  2155. getPrometheusIsInstalled,
  2156. getRegistryIntegrations,
  2157. getReleaseToken,
  2158. getReleaseSteps,
  2159. getRepoIntegrations,
  2160. getSlackIntegrations,
  2161. getRepos,
  2162. getRevisions,
  2163. getTemplateInfo,
  2164. getTemplateUpgradeNotes,
  2165. getTemplates,
  2166. getHelmRepos,
  2167. getChartsFromHelmRepo,
  2168. getChartInfoFromHelmRepo,
  2169. linkGithubProject,
  2170. getGithubAccounts,
  2171. listConfigMaps,
  2172. logInUser,
  2173. logOutUser,
  2174. registerUser,
  2175. rollbackChart,
  2176. uninstallTemplate,
  2177. updateUser,
  2178. renameConfigMap,
  2179. updateConfigMap,
  2180. upgradeChartValues,
  2181. deleteJob,
  2182. stopJob,
  2183. updateInvite,
  2184. listAPITokens,
  2185. getAPIToken,
  2186. revokeAPIToken,
  2187. createAPIToken,
  2188. createPolicy,
  2189. getAvailableRoles,
  2190. getCollaborators,
  2191. updateCollaborator,
  2192. removeCollaborator,
  2193. getPolicyDocument,
  2194. createWebhookToken,
  2195. getUsage,
  2196. getCustomerToken,
  2197. getHasBilling,
  2198. getOnboardingState,
  2199. saveOnboardingState,
  2200. getOnboardingInfra,
  2201. getOnboardingRegistry,
  2202. detectPorterAgent,
  2203. installPorterAgent,
  2204. getKubeEvents,
  2205. getKubeEvent,
  2206. getLogBuckets,
  2207. getLogBucketLogs,
  2208. getCanCreateProject,
  2209. createEnvGroup,
  2210. updateEnvGroup,
  2211. listEnvGroups,
  2212. getEnvGroup,
  2213. deleteEnvGroup,
  2214. addApplicationToEnvGroup,
  2215. removeApplicationFromEnvGroup,
  2216. provisionDatabase,
  2217. getDatabases,
  2218. getPreviousLogsForContainer,
  2219. getIncidents,
  2220. getIncidentsByReleaseName,
  2221. getIncidentById,
  2222. getIncidentLogsByLogId,
  2223. upgradePorterAgent,
  2224. deletePRDeployment,
  2225. updateBuildConfig,
  2226. updateGitActionConfig,
  2227. reRunGHWorkflow,
  2228. triggerPreviewEnvWorkflow,
  2229. getTagsByProjectId,
  2230. createTag,
  2231. updateReleaseTags,
  2232. getGitProviders,
  2233. getGitlabRepos,
  2234. getGitlabBranches,
  2235. getGitlabFolderContent,
  2236. // STACKS
  2237. listStacks,
  2238. getStack,
  2239. getStackRevision,
  2240. createStack,
  2241. updateStack,
  2242. rollbackStack,
  2243. deleteStack,
  2244. updateStackSourceConfig,
  2245. addStackAppResource,
  2246. removeStackAppResource,
  2247. addStackEnvGroup,
  2248. removeStackEnvGroup,
  2249. // STATUS
  2250. getGithubStatus,
  2251. // ROLES
  2252. listRoles,
  2253. getRole,
  2254. createRole,
  2255. updateRole,
  2256. deleteRole,
  2257. getScopeHierarchy,
  2258. };