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

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

import {
  zAccessServiceCreateApiKeyBody,
  zAccessServiceCreateApiKeyPath,
  zAccessServiceCreateApiKeyResponse,
  zAccessServiceDeleteApiKeyPath,
  zAccessServiceDeleteApiKeyResponse,
  zAccessServiceGetAccessChannelsPath,
  zAccessServiceGetAccessChannelsResponse,
  zAccessServiceGetAccessPolicyPath,
  zAccessServiceGetAccessPolicyResponse,
  zAccessServiceListApiKeysPath,
  zAccessServiceListApiKeysResponse,
  zAccessServicePutAccessPolicyBody,
  zAccessServicePutAccessPolicyPath,
  zAccessServicePutAccessPolicyResponse,
  zAccessServiceUpdateAccessChannelsBody,
  zAccessServiceUpdateAccessChannelsPath,
  zAccessServiceUpdateAccessChannelsResponse,
  zAppInstanceServiceCreateAppInstanceBody,
  zAppInstanceServiceCreateAppInstanceResponse,
  zAppInstanceServiceDeleteAppInstancePath,
  zAppInstanceServiceDeleteAppInstanceResponse,
  zAppInstanceServiceGetAppInstancePath,
  zAppInstanceServiceGetAppInstanceResponse,
  zAppInstanceServiceListAppInstancesQuery,
  zAppInstanceServiceListAppInstancesResponse,
  zAppInstanceServiceUpdateAppInstanceBody,
  zAppInstanceServiceUpdateAppInstancePath,
  zAppInstanceServiceUpdateAppInstanceResponse,
  zDeploymentServiceCancelDeploymentBody,
  zDeploymentServiceCancelDeploymentPath,
  zDeploymentServiceCancelDeploymentResponse,
  zDeploymentServiceCreateInitialDeploymentFromDslBody,
  zDeploymentServiceCreateInitialDeploymentFromDslResponse,
  zDeploymentServiceCreateInitialDeploymentFromSourceAppBody,
  zDeploymentServiceCreateInitialDeploymentFromSourceAppResponse,
  zDeploymentServiceDeployBody,
  zDeploymentServiceDeployPath,
  zDeploymentServiceDeployResponse,
  zDeploymentServiceListDeploymentsPath,
  zDeploymentServiceListDeploymentsQuery,
  zDeploymentServiceListDeploymentsResponse,
  zDeploymentServiceListEnvironmentDeploymentsPath,
  zDeploymentServiceListEnvironmentDeploymentsResponse,
  zDeploymentServicePromoteBody,
  zDeploymentServicePromotePath,
  zDeploymentServicePromoteResponse,
  zDeploymentServiceRollbackBody,
  zDeploymentServiceRollbackPath,
  zDeploymentServiceRollbackResponse,
  zDeploymentServiceUndeployBody,
  zDeploymentServiceUndeployPath,
  zDeploymentServiceUndeployResponse,
  zEnvironmentServiceListDeployableEnvironmentsQuery,
  zEnvironmentServiceListDeployableEnvironmentsResponse,
  zReleaseServiceCreateReleaseFromDslBody,
  zReleaseServiceCreateReleaseFromDslResponse,
  zReleaseServiceCreateReleaseFromSourceAppBody,
  zReleaseServiceCreateReleaseFromSourceAppResponse,
  zReleaseServiceDeleteReleasePath,
  zReleaseServiceDeleteReleaseResponse,
  zReleaseServiceGetDeploymentOptionsFromDslBody,
  zReleaseServiceGetDeploymentOptionsFromDslResponse,
  zReleaseServiceGetDeploymentOptionsFromSourceAppBody,
  zReleaseServiceGetDeploymentOptionsFromSourceAppResponse,
  zReleaseServiceGetReleasePath,
  zReleaseServiceGetReleaseResponse,
  zReleaseServiceListReleaseCredentialCandidatesPath,
  zReleaseServiceListReleaseCredentialCandidatesResponse,
  zReleaseServiceListReleasesPath,
  zReleaseServiceListReleasesQuery,
  zReleaseServiceListReleasesResponse,
  zReleaseServiceUpdateReleaseBody,
  zReleaseServiceUpdateReleasePath,
  zReleaseServiceUpdateReleaseResponse,
} from './zod.gen'

export const deleteApiKey = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'AccessService_DeleteApiKey',
    path: '/enterprise/app-deploy/api-keys/{apiKeyId}',
    tags: ['AccessService'],
  })
  .input(z.object({ params: zAccessServiceDeleteApiKeyPath }))
  .output(zAccessServiceDeleteApiKeyResponse)

export const getAccessChannels = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'AccessService_GetAccessChannels',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/access-channels',
    tags: ['AccessService'],
  })
  .input(z.object({ params: zAccessServiceGetAccessChannelsPath }))
  .output(zAccessServiceGetAccessChannelsResponse)

export const updateAccessChannels = oc
  .route({
    inputStructure: 'detailed',
    method: 'PUT',
    operationId: 'AccessService_UpdateAccessChannels',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/access-channels',
    tags: ['AccessService'],
  })
  .input(
    z.object({
      body: zAccessServiceUpdateAccessChannelsBody,
      params: zAccessServiceUpdateAccessChannelsPath,
    }),
  )
  .output(zAccessServiceUpdateAccessChannelsResponse)

export const getAccessPolicy = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'AccessService_GetAccessPolicy',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/access-policy',
    tags: ['AccessService'],
  })
  .input(z.object({ params: zAccessServiceGetAccessPolicyPath }))
  .output(zAccessServiceGetAccessPolicyResponse)

export const putAccessPolicy = oc
  .route({
    inputStructure: 'detailed',
    method: 'PUT',
    operationId: 'AccessService_PutAccessPolicy',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/access-policy',
    tags: ['AccessService'],
  })
  .input(
    z.object({
      body: zAccessServicePutAccessPolicyBody,
      params: zAccessServicePutAccessPolicyPath,
    }),
  )
  .output(zAccessServicePutAccessPolicyResponse)

export const listApiKeys = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'AccessService_ListApiKeys',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/api-keys',
    tags: ['AccessService'],
  })
  .input(z.object({ params: zAccessServiceListApiKeysPath }))
  .output(zAccessServiceListApiKeysResponse)

export const createApiKey = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'AccessService_CreateApiKey',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/api-keys',
    tags: ['AccessService'],
  })
  .input(z.object({ body: zAccessServiceCreateApiKeyBody, params: zAccessServiceCreateApiKeyPath }))
  .output(zAccessServiceCreateApiKeyResponse)

export const accessService = {
  deleteApiKey,
  getAccessChannels,
  updateAccessChannels,
  getAccessPolicy,
  putAccessPolicy,
  listApiKeys,
  createApiKey,
}

export const listAppInstances = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'AppInstanceService_ListAppInstances',
    path: '/enterprise/app-deploy/app-instances',
    tags: ['AppInstanceService'],
  })
  .input(z.object({ query: zAppInstanceServiceListAppInstancesQuery.optional() }))
  .output(zAppInstanceServiceListAppInstancesResponse)

export const createAppInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'AppInstanceService_CreateAppInstance',
    path: '/enterprise/app-deploy/app-instances',
    tags: ['AppInstanceService'],
  })
  .input(z.object({ body: zAppInstanceServiceCreateAppInstanceBody }))
  .output(zAppInstanceServiceCreateAppInstanceResponse)

export const deleteAppInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'AppInstanceService_DeleteAppInstance',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}',
    tags: ['AppInstanceService'],
  })
  .input(z.object({ params: zAppInstanceServiceDeleteAppInstancePath }))
  .output(zAppInstanceServiceDeleteAppInstanceResponse)

export const getAppInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'AppInstanceService_GetAppInstance',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}',
    tags: ['AppInstanceService'],
  })
  .input(z.object({ params: zAppInstanceServiceGetAppInstancePath }))
  .output(zAppInstanceServiceGetAppInstanceResponse)

export const updateAppInstance = oc
  .route({
    inputStructure: 'detailed',
    method: 'PATCH',
    operationId: 'AppInstanceService_UpdateAppInstance',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}',
    tags: ['AppInstanceService'],
  })
  .input(
    z.object({
      body: zAppInstanceServiceUpdateAppInstanceBody,
      params: zAppInstanceServiceUpdateAppInstancePath,
    }),
  )
  .output(zAppInstanceServiceUpdateAppInstanceResponse)

export const appInstanceService = {
  listAppInstances,
  createAppInstance,
  deleteAppInstance,
  getAppInstance,
  updateAppInstance,
}

export const listDeployments = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'DeploymentService_ListDeployments',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/deployments',
    tags: ['DeploymentService'],
  })
  .input(
    z.object({
      params: zDeploymentServiceListDeploymentsPath,
      query: zDeploymentServiceListDeploymentsQuery.optional(),
    }),
  )
  .output(zDeploymentServiceListDeploymentsResponse)

export const listEnvironmentDeployments = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'DeploymentService_ListEnvironmentDeployments',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environment-deployments',
    tags: ['DeploymentService'],
  })
  .input(z.object({ params: zDeploymentServiceListEnvironmentDeploymentsPath }))
  .output(zDeploymentServiceListEnvironmentDeploymentsResponse)

export const cancelDeployment = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'DeploymentService_CancelDeployment',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/cancel',
    tags: ['DeploymentService'],
  })
  .input(
    z.object({
      body: zDeploymentServiceCancelDeploymentBody,
      params: zDeploymentServiceCancelDeploymentPath,
    }),
  )
  .output(zDeploymentServiceCancelDeploymentResponse)

export const deploy = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'DeploymentService_Deploy',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/deploy',
    tags: ['DeploymentService'],
  })
  .input(z.object({ body: zDeploymentServiceDeployBody, params: zDeploymentServiceDeployPath }))
  .output(zDeploymentServiceDeployResponse)

export const rollback = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'DeploymentService_Rollback',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/rollback',
    tags: ['DeploymentService'],
  })
  .input(z.object({ body: zDeploymentServiceRollbackBody, params: zDeploymentServiceRollbackPath }))
  .output(zDeploymentServiceRollbackResponse)

export const undeploy = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'DeploymentService_Undeploy',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/environments/{environmentId}/undeploy',
    tags: ['DeploymentService'],
  })
  .input(z.object({ body: zDeploymentServiceUndeployBody, params: zDeploymentServiceUndeployPath }))
  .output(zDeploymentServiceUndeployResponse)

export const promote = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'DeploymentService_Promote',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/promote',
    tags: ['DeploymentService'],
  })
  .input(z.object({ body: zDeploymentServicePromoteBody, params: zDeploymentServicePromotePath }))
  .output(zDeploymentServicePromoteResponse)

export const createInitialDeploymentFromDsl = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'DeploymentService_CreateInitialDeploymentFromDSL',
    path: '/enterprise/app-deploy/initial-deployments/dsl',
    tags: ['DeploymentService'],
  })
  .input(z.object({ body: zDeploymentServiceCreateInitialDeploymentFromDslBody }))
  .output(zDeploymentServiceCreateInitialDeploymentFromDslResponse)

export const createInitialDeploymentFromSourceApp = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'DeploymentService_CreateInitialDeploymentFromSourceApp',
    path: '/enterprise/app-deploy/initial-deployments/source-app',
    tags: ['DeploymentService'],
  })
  .input(z.object({ body: zDeploymentServiceCreateInitialDeploymentFromSourceAppBody }))
  .output(zDeploymentServiceCreateInitialDeploymentFromSourceAppResponse)

export const deploymentService = {
  listDeployments,
  listEnvironmentDeployments,
  cancelDeployment,
  deploy,
  rollback,
  undeploy,
  promote,
  createInitialDeploymentFromDsl,
  createInitialDeploymentFromSourceApp,
}

export const listReleases = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'ReleaseService_ListReleases',
    path: '/enterprise/app-deploy/app-instances/{appInstanceId}/releases',
    tags: ['ReleaseService'],
  })
  .input(
    z.object({
      params: zReleaseServiceListReleasesPath,
      query: zReleaseServiceListReleasesQuery.optional(),
    }),
  )
  .output(zReleaseServiceListReleasesResponse)

export const getDeploymentOptionsFromDsl = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'ReleaseService_GetDeploymentOptionsFromDSL',
    path: '/enterprise/app-deploy/deployment-options/dsl',
    tags: ['ReleaseService'],
  })
  .input(z.object({ body: zReleaseServiceGetDeploymentOptionsFromDslBody }))
  .output(zReleaseServiceGetDeploymentOptionsFromDslResponse)

export const getDeploymentOptionsFromSourceApp = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'ReleaseService_GetDeploymentOptionsFromSourceApp',
    path: '/enterprise/app-deploy/deployment-options/source-app',
    tags: ['ReleaseService'],
  })
  .input(z.object({ body: zReleaseServiceGetDeploymentOptionsFromSourceAppBody }))
  .output(zReleaseServiceGetDeploymentOptionsFromSourceAppResponse)

export const createReleaseFromDsl = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'ReleaseService_CreateReleaseFromDSL',
    path: '/enterprise/app-deploy/releases/dsl',
    tags: ['ReleaseService'],
  })
  .input(z.object({ body: zReleaseServiceCreateReleaseFromDslBody }))
  .output(zReleaseServiceCreateReleaseFromDslResponse)

export const createReleaseFromSourceApp = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'ReleaseService_CreateReleaseFromSourceApp',
    path: '/enterprise/app-deploy/releases/source-app',
    tags: ['ReleaseService'],
  })
  .input(z.object({ body: zReleaseServiceCreateReleaseFromSourceAppBody }))
  .output(zReleaseServiceCreateReleaseFromSourceAppResponse)

export const deleteRelease = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'ReleaseService_DeleteRelease',
    path: '/enterprise/app-deploy/releases/{releaseId}',
    tags: ['ReleaseService'],
  })
  .input(z.object({ params: zReleaseServiceDeleteReleasePath }))
  .output(zReleaseServiceDeleteReleaseResponse)

export const getRelease = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'ReleaseService_GetRelease',
    path: '/enterprise/app-deploy/releases/{releaseId}',
    tags: ['ReleaseService'],
  })
  .input(z.object({ params: zReleaseServiceGetReleasePath }))
  .output(zReleaseServiceGetReleaseResponse)

export const updateRelease = oc
  .route({
    inputStructure: 'detailed',
    method: 'PATCH',
    operationId: 'ReleaseService_UpdateRelease',
    path: '/enterprise/app-deploy/releases/{releaseId}',
    tags: ['ReleaseService'],
  })
  .input(
    z.object({ body: zReleaseServiceUpdateReleaseBody, params: zReleaseServiceUpdateReleasePath }),
  )
  .output(zReleaseServiceUpdateReleaseResponse)

export const listReleaseCredentialCandidates = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'ReleaseService_ListReleaseCredentialCandidates',
    path: '/enterprise/app-deploy/releases/{releaseId}/credential-candidates',
    tags: ['ReleaseService'],
  })
  .input(z.object({ params: zReleaseServiceListReleaseCredentialCandidatesPath }))
  .output(zReleaseServiceListReleaseCredentialCandidatesResponse)

export const releaseService = {
  listReleases,
  getDeploymentOptionsFromDsl,
  getDeploymentOptionsFromSourceApp,
  createReleaseFromDsl,
  createReleaseFromSourceApp,
  deleteRelease,
  getRelease,
  updateRelease,
  listReleaseCredentialCandidates,
}

export const listDeployableEnvironments = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'EnvironmentService_ListDeployableEnvironments',
    path: '/enterprise/app-deploy/deployable-environments',
    tags: ['EnvironmentService'],
  })
  .input(z.object({ query: zEnvironmentServiceListDeployableEnvironmentsQuery.optional() }))
  .output(zEnvironmentServiceListDeployableEnvironmentsResponse)

export const environmentService = {
  listDeployableEnvironments,
}

export const contract = {
  accessService,
  appInstanceService,
  deploymentService,
  releaseService,
  environmentService,
}
