api.tsx 60 KB

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