// This file is auto-generated by @hey-api/openapi-ts

import { oc } from '@orpc/contract'
import * as z from 'zod'

import {
  zConsoleSsoOAuth2LoginResponse,
  zConsoleSsoOidcLoginResponse,
  zConsoleSsoSamlLoginResponse,
  zEnterpriseAppDeployConsoleCancelRuntimeDeploymentBody,
  zEnterpriseAppDeployConsoleCancelRuntimeDeploymentPath,
  zEnterpriseAppDeployConsoleCancelRuntimeDeploymentResponse,
  zEnterpriseAppDeployConsoleCreateAppInstanceBody,
  zEnterpriseAppDeployConsoleCreateAppInstanceResponse,
  zEnterpriseAppDeployConsoleCreateDeploymentBody,
  zEnterpriseAppDeployConsoleCreateDeploymentPath,
  zEnterpriseAppDeployConsoleCreateDeploymentResponse,
  zEnterpriseAppDeployConsoleCreateDeveloperApiKeyBody,
  zEnterpriseAppDeployConsoleCreateDeveloperApiKeyPath,
  zEnterpriseAppDeployConsoleCreateDeveloperApiKeyResponse,
  zEnterpriseAppDeployConsoleCreateReleaseBody,
  zEnterpriseAppDeployConsoleCreateReleasePath,
  zEnterpriseAppDeployConsoleCreateReleaseResponse,
  zEnterpriseAppDeployConsoleDeleteAppInstancePath,
  zEnterpriseAppDeployConsoleDeleteAppInstanceResponse,
  zEnterpriseAppDeployConsoleDeleteDeveloperApiKeyPath,
  zEnterpriseAppDeployConsoleDeleteDeveloperApiKeyResponse,
  zEnterpriseAppDeployConsoleGetAppInstanceAccessPath,
  zEnterpriseAppDeployConsoleGetAppInstanceAccessResponse,
  zEnterpriseAppDeployConsoleGetAppInstanceOverviewPath,
  zEnterpriseAppDeployConsoleGetAppInstanceOverviewResponse,
  zEnterpriseAppDeployConsoleGetAppInstanceSettingsPath,
  zEnterpriseAppDeployConsoleGetAppInstanceSettingsResponse,
  zEnterpriseAppDeployConsoleGetEnvironmentAccessPolicyPath,
  zEnterpriseAppDeployConsoleGetEnvironmentAccessPolicyResponse,
  zEnterpriseAppDeployConsoleListAppInstancesQuery,
  zEnterpriseAppDeployConsoleListAppInstancesResponse,
  zEnterpriseAppDeployConsoleListDeploymentBindingOptionsPath,
  zEnterpriseAppDeployConsoleListDeploymentBindingOptionsResponse,
  zEnterpriseAppDeployConsoleListDeploymentEnvironmentOptionsResponse,
  zEnterpriseAppDeployConsoleListReleasesPath,
  zEnterpriseAppDeployConsoleListReleasesQuery,
  zEnterpriseAppDeployConsoleListReleasesResponse,
  zEnterpriseAppDeployConsoleListRuntimeInstancesPath,
  zEnterpriseAppDeployConsoleListRuntimeInstancesResponse,
  zEnterpriseAppDeployConsolePreviewReleaseBody,
  zEnterpriseAppDeployConsolePreviewReleasePath,
  zEnterpriseAppDeployConsolePreviewReleaseResponse,
  zEnterpriseAppDeployConsoleSearchAccessSubjectsPath,
  zEnterpriseAppDeployConsoleSearchAccessSubjectsQuery,
  zEnterpriseAppDeployConsoleSearchAccessSubjectsResponse,
  zEnterpriseAppDeployConsoleUndeployRuntimeInstanceBody,
  zEnterpriseAppDeployConsoleUndeployRuntimeInstancePath,
  zEnterpriseAppDeployConsoleUndeployRuntimeInstanceResponse,
  zEnterpriseAppDeployConsoleUpdateAccessChannelsBody,
  zEnterpriseAppDeployConsoleUpdateAccessChannelsPath,
  zEnterpriseAppDeployConsoleUpdateAccessChannelsResponse,
  zEnterpriseAppDeployConsoleUpdateAppInstanceBody,
  zEnterpriseAppDeployConsoleUpdateAppInstancePath,
  zEnterpriseAppDeployConsoleUpdateAppInstanceResponse,
  zEnterpriseAppDeployConsoleUpdateDeveloperApiBody,
  zEnterpriseAppDeployConsoleUpdateDeveloperApiPath,
  zEnterpriseAppDeployConsoleUpdateDeveloperApiResponse,
  zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyBody,
  zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyPath,
  zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyResponse,
  zWebAppAuthGetGroupSubjectsQuery,
  zWebAppAuthGetGroupSubjectsResponse,
  zWebAppAuthGetWebAppAccessModeQuery,
  zWebAppAuthGetWebAppAccessModeResponse,
  zWebAppAuthGetWebAppWhitelistSubjectsQuery,
  zWebAppAuthGetWebAppWhitelistSubjectsResponse,
  zWebAppAuthIsUserAllowedToAccessWebAppQuery,
  zWebAppAuthIsUserAllowedToAccessWebAppResponse,
  zWebAppAuthSearchForWhilteListCandidatesQuery,
  zWebAppAuthSearchForWhilteListCandidatesResponse,
  zWebAppAuthUpdateWebAppWhitelistSubjectsBody,
  zWebAppAuthUpdateWebAppWhitelistSubjectsResponse,
} from './zod.gen'

export const listAppInstances = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_ListAppInstances',
    path: '/enterprise/app-instances',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ query: zEnterpriseAppDeployConsoleListAppInstancesQuery.optional() }))
  .output(zEnterpriseAppDeployConsoleListAppInstancesResponse)

export const createAppInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'EnterpriseAppDeployConsole_CreateAppInstance',
    path: '/enterprise/app-instances',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ body: zEnterpriseAppDeployConsoleCreateAppInstanceBody }))
  .output(zEnterpriseAppDeployConsoleCreateAppInstanceResponse)

export const deleteAppInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'EnterpriseAppDeployConsole_DeleteAppInstance',
    path: '/enterprise/app-instances/{appInstanceId}',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleDeleteAppInstancePath }))
  .output(zEnterpriseAppDeployConsoleDeleteAppInstanceResponse)

export const updateAppInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'PATCH',
    operationId: 'EnterpriseAppDeployConsole_UpdateAppInstance',
    path: '/enterprise/app-instances/{appInstanceId}',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleUpdateAppInstanceBody,
      params: zEnterpriseAppDeployConsoleUpdateAppInstancePath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleUpdateAppInstanceResponse)

export const getAppInstanceAccess = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_GetAppInstanceAccess',
    path: '/enterprise/app-instances/{appInstanceId}/access',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleGetAppInstanceAccessPath }))
  .output(zEnterpriseAppDeployConsoleGetAppInstanceAccessResponse)

export const updateAccessChannels = oc
  .route({
    inputStructure: 'detailed',
    method: 'PATCH',
    operationId: 'EnterpriseAppDeployConsole_UpdateAccessChannels',
    path: '/enterprise/app-instances/{appInstanceId}/access-channels',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleUpdateAccessChannelsBody,
      params: zEnterpriseAppDeployConsoleUpdateAccessChannelsPath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleUpdateAccessChannelsResponse)

export const searchAccessSubjects = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_SearchAccessSubjects',
    path: '/enterprise/app-instances/{appInstanceId}/access-subjects:search',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      params: zEnterpriseAppDeployConsoleSearchAccessSubjectsPath,
      query: zEnterpriseAppDeployConsoleSearchAccessSubjectsQuery.optional(),
    }),
  )
  .output(zEnterpriseAppDeployConsoleSearchAccessSubjectsResponse)

export const createDeveloperApiKey = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'EnterpriseAppDeployConsole_CreateDeveloperApiKey',
    path: '/enterprise/app-instances/{appInstanceId}/api-keys',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleCreateDeveloperApiKeyBody,
      params: zEnterpriseAppDeployConsoleCreateDeveloperApiKeyPath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleCreateDeveloperApiKeyResponse)

export const deleteDeveloperApiKey = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'EnterpriseAppDeployConsole_DeleteDeveloperApiKey',
    path: '/enterprise/app-instances/{appInstanceId}/api-keys/{apiKeyId}',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleDeleteDeveloperApiKeyPath }))
  .output(zEnterpriseAppDeployConsoleDeleteDeveloperApiKeyResponse)

export const listDeploymentBindingOptions = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_ListDeploymentBindingOptions',
    path: '/enterprise/app-instances/{appInstanceId}/deployment-binding-options',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleListDeploymentBindingOptionsPath }))
  .output(zEnterpriseAppDeployConsoleListDeploymentBindingOptionsResponse)

export const createDeployment = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'EnterpriseAppDeployConsole_CreateDeployment',
    path: '/enterprise/app-instances/{appInstanceId}/deployments',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleCreateDeploymentBody,
      params: zEnterpriseAppDeployConsoleCreateDeploymentPath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleCreateDeploymentResponse)

export const updateDeveloperApi = oc
  .route({
    inputStructure: 'detailed',
    method: 'PATCH',
    operationId: 'EnterpriseAppDeployConsole_UpdateDeveloperApi',
    path: '/enterprise/app-instances/{appInstanceId}/developer-api',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleUpdateDeveloperApiBody,
      params: zEnterpriseAppDeployConsoleUpdateDeveloperApiPath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleUpdateDeveloperApiResponse)

export const getEnvironmentAccessPolicy = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_GetEnvironmentAccessPolicy',
    path: '/enterprise/app-instances/{appInstanceId}/environments/{environmentId}/access-policy',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleGetEnvironmentAccessPolicyPath }))
  .output(zEnterpriseAppDeployConsoleGetEnvironmentAccessPolicyResponse)

export const updateEnvironmentAccessPolicy = oc
  .route({
    inputStructure: 'detailed',
    method: 'PUT',
    operationId: 'EnterpriseAppDeployConsole_UpdateEnvironmentAccessPolicy',
    path: '/enterprise/app-instances/{appInstanceId}/environments/{environmentId}/access-policy',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyBody,
      params: zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyPath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyResponse)

export const getAppInstanceOverview = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_GetAppInstanceOverview',
    path: '/enterprise/app-instances/{appInstanceId}/overview',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleGetAppInstanceOverviewPath }))
  .output(zEnterpriseAppDeployConsoleGetAppInstanceOverviewResponse)

export const listReleases = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_ListReleases',
    path: '/enterprise/app-instances/{appInstanceId}/releases',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      params: zEnterpriseAppDeployConsoleListReleasesPath,
      query: zEnterpriseAppDeployConsoleListReleasesQuery.optional(),
    }),
  )
  .output(zEnterpriseAppDeployConsoleListReleasesResponse)

export const createRelease = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'EnterpriseAppDeployConsole_CreateRelease',
    path: '/enterprise/app-instances/{appInstanceId}/releases',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleCreateReleaseBody,
      params: zEnterpriseAppDeployConsoleCreateReleasePath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleCreateReleaseResponse)

export const previewRelease = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'EnterpriseAppDeployConsole_PreviewRelease',
    path: '/enterprise/app-instances/{appInstanceId}/releases:preview',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsolePreviewReleaseBody,
      params: zEnterpriseAppDeployConsolePreviewReleasePath,
    }),
  )
  .output(zEnterpriseAppDeployConsolePreviewReleaseResponse)

export const listRuntimeInstances = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_ListRuntimeInstances',
    path: '/enterprise/app-instances/{appInstanceId}/runtime-instances',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleListRuntimeInstancesPath }))
  .output(zEnterpriseAppDeployConsoleListRuntimeInstancesResponse)

export const cancelRuntimeDeployment = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'EnterpriseAppDeployConsole_CancelRuntimeDeployment',
    path: '/enterprise/app-instances/{appInstanceId}/runtime-instances/{runtimeInstanceId}/deployment:cancel',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleCancelRuntimeDeploymentBody,
      params: zEnterpriseAppDeployConsoleCancelRuntimeDeploymentPath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleCancelRuntimeDeploymentResponse)

export const undeployRuntimeInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'EnterpriseAppDeployConsole_UndeployRuntimeInstance',
    path: '/enterprise/app-instances/{appInstanceId}/runtime-instances/{runtimeInstanceId}:undeploy',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(
    z.object({
      body: zEnterpriseAppDeployConsoleUndeployRuntimeInstanceBody,
      params: zEnterpriseAppDeployConsoleUndeployRuntimeInstancePath,
    }),
  )
  .output(zEnterpriseAppDeployConsoleUndeployRuntimeInstanceResponse)

export const getAppInstanceSettings = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_GetAppInstanceSettings',
    path: '/enterprise/app-instances/{appInstanceId}/settings',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .input(z.object({ params: zEnterpriseAppDeployConsoleGetAppInstanceSettingsPath }))
  .output(zEnterpriseAppDeployConsoleGetAppInstanceSettingsResponse)

export const listDeploymentEnvironmentOptions = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnterpriseAppDeployConsole_ListDeploymentEnvironmentOptions',
    path: '/enterprise/deployment-environment-options',
    tags: ['EnterpriseAppDeployConsole'],
  })
  .output(zEnterpriseAppDeployConsoleListDeploymentEnvironmentOptionsResponse)

export const enterpriseAppDeployConsole = {
  listAppInstances,
  createAppInstance,
  deleteAppInstance,
  updateAppInstance,
  getAppInstanceAccess,
  updateAccessChannels,
  searchAccessSubjects,
  createDeveloperApiKey,
  deleteDeveloperApiKey,
  listDeploymentBindingOptions,
  createDeployment,
  updateDeveloperApi,
  getEnvironmentAccessPolicy,
  updateEnvironmentAccessPolicy,
  getAppInstanceOverview,
  listReleases,
  createRelease,
  previewRelease,
  listRuntimeInstances,
  cancelRuntimeDeployment,
  undeployRuntimeInstance,
  getAppInstanceSettings,
  listDeploymentEnvironmentOptions,
}

export const oAuth2Login = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'ConsoleSSO_OAuth2Login',
    path: '/enterprise/sso/oauth2/login',
    tags: ['ConsoleSSO'],
  })
  .output(zConsoleSsoOAuth2LoginResponse)

export const oidcLogin = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'ConsoleSSO_OIDCLogin',
    path: '/enterprise/sso/oidc/login',
    tags: ['ConsoleSSO'],
  })
  .output(zConsoleSsoOidcLoginResponse)

export const samlLogin = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'ConsoleSSO_SAMLLogin',
    path: '/enterprise/sso/saml/login',
    tags: ['ConsoleSSO'],
  })
  .output(zConsoleSsoSamlLoginResponse)

export const consoleSso = {
  oAuth2Login,
  oidcLogin,
  samlLogin,
}

export const getWebAppAccessMode = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'WebAppAuth_GetWebAppAccessMode',
    path: '/enterprise/webapp/app/access-mode',
    tags: ['WebAppAuth'],
  })
  .input(z.object({ query: zWebAppAuthGetWebAppAccessModeQuery.optional() }))
  .output(zWebAppAuthGetWebAppAccessModeResponse)

export const updateWebAppWhitelistSubjects = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'WebAppAuth_UpdateWebAppWhitelistSubjects',
    path: '/enterprise/webapp/app/access-mode',
    tags: ['WebAppAuth'],
  })
  .input(z.object({ body: zWebAppAuthUpdateWebAppWhitelistSubjectsBody }))
  .output(zWebAppAuthUpdateWebAppWhitelistSubjectsResponse)

export const searchForWhilteListCandidates = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'WebAppAuth_SearchForWhilteListCandidates',
    path: '/enterprise/webapp/app/subject/search',
    tags: ['WebAppAuth'],
  })
  .input(z.object({ query: zWebAppAuthSearchForWhilteListCandidatesQuery.optional() }))
  .output(zWebAppAuthSearchForWhilteListCandidatesResponse)

export const getWebAppWhitelistSubjects = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'WebAppAuth_GetWebAppWhitelistSubjects',
    path: '/enterprise/webapp/app/subjects',
    tags: ['WebAppAuth'],
  })
  .input(z.object({ query: zWebAppAuthGetWebAppWhitelistSubjectsQuery.optional() }))
  .output(zWebAppAuthGetWebAppWhitelistSubjectsResponse)

export const getGroupSubjects = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'WebAppAuth_GetGroupSubjects',
    path: '/enterprise/webapp/group/subjects',
    tags: ['WebAppAuth'],
  })
  .input(z.object({ query: zWebAppAuthGetGroupSubjectsQuery.optional() }))
  .output(zWebAppAuthGetGroupSubjectsResponse)

export const isUserAllowedToAccessWebApp = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'WebAppAuth_IsUserAllowedToAccessWebApp',
    path: '/enterprise/webapp/permission',
    tags: ['WebAppAuth'],
  })
  .input(z.object({ query: zWebAppAuthIsUserAllowedToAccessWebAppQuery.optional() }))
  .output(zWebAppAuthIsUserAllowedToAccessWebAppResponse)

export const webAppAuth = {
  getWebAppAccessMode,
  updateWebAppWhitelistSubjects,
  searchForWhilteListCandidates,
  getWebAppWhitelistSubjects,
  getGroupSubjects,
  isUserAllowedToAccessWebApp,
}

export const contract = {
  enterpriseAppDeployConsole,
  consoleSso,
  webAppAuth,
}
