api.tsx 72 KB

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