api.tsx 56 KB

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