api.tsx 77 KB

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