api.tsx 58 KB

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