api.tsx 74 KB

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