api.tsx 60 KB

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