api.tsx 48 KB

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