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

import * as z from 'zod'

export const zAccessChannels = z.object({
  id: z.string().optional(),
  appInstanceId: z.string().optional(),
  webAppEnabled: z.boolean().optional(),
  developerApiEnabled: z.boolean().optional(),
  updatedBy: z.string().optional(),
  createdAt: z.string().optional(),
  updatedAt: z.string().optional(),
})

export const zAccessSubject = z.object({
  subjectType: z
    .enum(['SUBJECT_TYPE_UNSPECIFIED', 'SUBJECT_TYPE_ACCOUNT', 'SUBJECT_TYPE_GROUP'])
    .optional(),
  subjectId: z.string().optional(),
})

export const zAccessPolicy = z.object({
  id: z.string().optional(),
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  mode: z
    .enum([
      'ACCESS_MODE_UNSPECIFIED',
      'ACCESS_MODE_PUBLIC',
      'ACCESS_MODE_PRIVATE',
      'ACCESS_MODE_PRIVATE_ALL',
    ])
    .optional(),
  subjects: z.array(zAccessSubject).optional(),
  createdAt: z.string().optional(),
  updatedAt: z.string().optional(),
})

export const zActor = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
})

export const zApiKey = z.object({
  id: z.string().optional(),
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  name: z.string().optional(),
  maskedToken: z.string().optional(),
  lastUsedAt: z.string().optional(),
  createdBy: zActor.optional(),
  createdAt: z.string().optional(),
})

export const zAppInstance = z.object({
  id: z.string().optional(),
  tenantId: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
  createdBy: z.string().optional(),
  updatedBy: z.string().optional(),
  createdAt: z.string().optional(),
  updatedAt: z.string().optional(),
})

export const zAppRunnerLog = z.object({
  id: z.string().optional(),
  timestamp: z.iso.datetime().optional(),
  workflowRunId: z.string().optional(),
  status: z.string().optional(),
  durationSeconds: z.number().optional(),
  totalTokens: z.string().optional(),
  workspaceId: z.string().optional(),
  environmentId: z.string().optional(),
  instanceId: z.string().optional(),
  endUser: z.string().optional(),
  invokeFrom: z.string().optional(),
  traceId: z.string().optional(),
  difyTraceId: z.string().optional(),
  body: z.string().optional(),
  attributesJson: z.string().optional(),
  resourceAttributesJson: z.string().optional(),
})

/**
 * BootstrapAssignment is one runtime_instance assignment in a runner's startup
 * baseline. operation is "load" or "unload".
 */
export const zBootstrapAssignment = z.object({
  appId: z.string().optional(),
  environmentId: z.string().optional(),
  workflowId: z.string().optional(),
  runtimeInstanceId: z.string().optional(),
  workspaceId: z.string().optional(),
  runtimeInstanceVersion: z.string().optional(),
  bindingSnapshotVersion: z.string().optional(),
  executionTokenVersion: z.string().optional(),
  executionToken: z.string().optional(),
  releaseId: z.string().optional(),
  operation: z.string().optional(),
  deploymentId: z.string().optional(),
  reportStatus: z.boolean().optional(),
})

export const zBootstrapRunnerReply = z.object({
  runnerId: z.string().optional(),
  assignmentRevision: z.string().optional(),
  assignments: z.array(zBootstrapAssignment).optional(),
})

export const zCancelDeploymentReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
})

export const zCreateApiKeyReply = z.object({
  apiKey: zApiKey.optional(),
  token: z.string().optional(),
})

export const zCreateApiKeyReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  name: z.string().optional(),
})

export const zCreateAppInstanceReply = z.object({
  appInstance: zAppInstance.optional(),
})

export const zCreateAppInstanceReq = z.object({
  name: z.string().optional(),
  description: z.string().optional(),
})

export const zCreateReleaseFromDslReq = z.object({
  appInstanceId: z.string().optional(),
  dsl: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
  createAppInstance: z.boolean().optional(),
})

export const zCreateReleaseFromSourceAppReq = z.object({
  appInstanceId: z.string().optional(),
  sourceAppId: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
  createAppInstance: z.boolean().optional(),
})

/**
 * CredentialCandidate is one tenant-visible credential a frontend may
 * pick for a credential slot. It carries no secret.
 */
export const zCredentialCandidate = z.object({
  credentialId: z.string().optional(),
  providerId: z.string().optional(),
  category: z
    .enum(['PLUGIN_CATEGORY_UNSPECIFIED', 'PLUGIN_CATEGORY_MODEL', 'PLUGIN_CATEGORY_TOOL'])
    .optional(),
  displayName: z.string().optional(),
  fromEnterprise: z.boolean().optional(),
})

/**
 * CredentialSelectionInput is one deploy-time plugin-credential
 * selection: a shared credential id chosen for a required DSL slot.
 */
export const zCredentialSelectionInput = z.object({
  providerId: z.string().optional(),
  category: z
    .enum(['PLUGIN_CATEGORY_UNSPECIFIED', 'PLUGIN_CATEGORY_MODEL', 'PLUGIN_CATEGORY_TOOL'])
    .optional(),
  credentialId: z.string().optional(),
})

/**
 * CredentialSlot is one model/tool plugin-credential requirement a
 * Release's DSL declares, paired with the candidates selectable for it.
 */
export const zCredentialSlot = z.object({
  providerId: z.string().optional(),
  category: z
    .enum(['PLUGIN_CATEGORY_UNSPECIFIED', 'PLUGIN_CATEGORY_MODEL', 'PLUGIN_CATEGORY_TOOL'])
    .optional(),
  candidates: z.array(zCredentialCandidate).optional(),
})

export const zDeleteApiKeyReply = z.record(z.string(), z.unknown())

export const zDeleteAppInstanceReply = z.record(z.string(), z.unknown())

export const zDeleteReleaseReply = z.record(z.string(), z.unknown())

export const zDeploymentOptionsAppInstanceDefaults = z.object({
  name: z.string().optional(),
  description: z.string().optional(),
})

export const zDeploymentOptionsReleaseDefaults = z.object({
  name: z.string().optional(),
  description: z.string().optional(),
})

export const zEnvVarInput = z.object({
  key: z.string().optional(),
  value: z.string().optional(),
})

export const zCreateInitialDeploymentFromDslReq = z.object({
  dsl: z.string().optional(),
  environmentId: z.string().optional(),
  appInstanceName: z.string().optional(),
  appInstanceDescription: z.string().optional(),
  releaseName: z.string().optional(),
  releaseDescription: z.string().optional(),
  credentials: z.array(zCredentialSelectionInput).optional(),
  envVars: z.array(zEnvVarInput).optional(),
  idempotencyKey: z.string().optional(),
  expectedDslDigest: z.string().optional(),
})

export const zCreateInitialDeploymentFromSourceAppReq = z.object({
  sourceAppId: z.string().optional(),
  environmentId: z.string().optional(),
  appInstanceName: z.string().optional(),
  appInstanceDescription: z.string().optional(),
  releaseName: z.string().optional(),
  releaseDescription: z.string().optional(),
  credentials: z.array(zCredentialSelectionInput).optional(),
  envVars: z.array(zEnvVarInput).optional(),
  idempotencyKey: z.string().optional(),
  expectedDslDigest: z.string().optional(),
})

export const zDeployReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  releaseId: z.string().optional(),
  credentials: z.array(zCredentialSelectionInput).optional(),
  envVars: z.array(zEnvVarInput).optional(),
  idempotencyKey: z.string().optional(),
  reuseEnvSnapshot: z.boolean().optional(),
})

export const zEnvVarSlot = z.object({
  key: z.string().optional(),
})

export const zDeploymentOptions = z.object({
  dslDigest: z.string().optional(),
  appInstanceDefaults: zDeploymentOptionsAppInstanceDefaults.optional(),
  releaseDefaults: zDeploymentOptionsReleaseDefaults.optional(),
  credentialSlots: z.array(zCredentialSlot).optional(),
  envVarSlots: z.array(zEnvVarSlot).optional(),
})

export const zEnvironmentDeploymentRecord = z.object({
  id: z.string().optional(),
  status: z
    .enum([
      'DEPLOYMENT_STATUS_UNSPECIFIED',
      'DEPLOYMENT_STATUS_DEPLOYING',
      'DEPLOYMENT_STATUS_READY',
      'DEPLOYMENT_STATUS_FAILED',
      'DEPLOYMENT_STATUS_CANCELLED',
    ])
    .optional(),
  createdAt: z.string().optional(),
  finalizedAt: z.string().optional(),
})

export const zEnvironmentError = z.object({
  code: z.string().optional(),
  message: z.string().optional(),
})

export const zEnvironment = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
  mode: z
    .enum(['ENVIRONMENT_MODE_UNSPECIFIED', 'ENVIRONMENT_MODE_SHARED', 'ENVIRONMENT_MODE_ISOLATED'])
    .optional(),
  backend: z
    .enum(['RUNTIME_BACKEND_UNSPECIFIED', 'RUNTIME_BACKEND_K8S', 'RUNTIME_BACKEND_EXTERNAL'])
    .optional(),
  namespace: z.string().optional(),
  apiServer: z.string().optional(),
  status: z
    .enum([
      'ENVIRONMENT_STATUS_UNSPECIFIED',
      'ENVIRONMENT_STATUS_ADMISSION',
      'ENVIRONMENT_STATUS_BOOTSTRAPPING',
      'ENVIRONMENT_STATUS_READY',
      'ENVIRONMENT_STATUS_FAILED',
    ])
    .optional(),
  statusMessage: z.string().optional(),
  lastError: zEnvironmentError.optional(),
  managedBy: z.string().optional(),
  createdAt: z.string().optional(),
  updatedAt: z.string().optional(),
  runtimeEndpoint: z.string().optional(),
  cpuCount: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
})

/**
 * Error is the wire failure shape carried on a Deployment or Ack.
 */
export const zError = z.object({
  phase: z.string().optional(),
  code: z.string().optional(),
  message: z.string().optional(),
  atUnix: z.string().optional(),
})

export const zGetAccessChannelsReply = z.object({
  accessChannels: zAccessChannels.optional(),
})

export const zGetAccessPolicyReply = z.object({
  policy: zAccessPolicy.optional(),
})

export const zGetAppInstanceReply = z.object({
  appInstance: zAppInstance.optional(),
})

export const zGetAppRunnerLogReply = z.object({
  data: zAppRunnerLog.optional(),
  lastArchived: z.iso.datetime().optional(),
})

export const zGetDeploymentOptionsFromDslReq = z.object({
  dsl: z.string().optional(),
})

export const zGetDeploymentOptionsFromSourceAppReq = z.object({
  sourceAppId: z.string().optional(),
})

export const zGetDeploymentOptionsReply = z.object({
  options: zDeploymentOptions.optional(),
})

export const zListApiKeysReply = z.object({
  data: z.array(zApiKey).optional(),
  apiUrl: z.string().optional(),
})

export const zListDeployableEnvironmentsReply = z.object({
  data: z.array(zEnvironment).optional(),
})

export const zListReleaseCredentialCandidatesReply = z.object({
  slots: z.array(zCredentialSlot).optional(),
})

export const zPromoteReq = z.object({
  appInstanceId: z.string().optional(),
  fromEnvironmentId: z.string().optional(),
  toEnvironmentId: z.string().optional(),
  sourceDeploymentId: z.string().optional(),
  credentials: z.array(zCredentialSelectionInput).optional(),
  envVars: z.array(zEnvVarInput).optional(),
  idempotencyKey: z.string().optional(),
})

export const zPutAccessPolicyReply = z.object({
  policy: zAccessPolicy.optional(),
})

export const zPutAccessPolicyReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  mode: z
    .enum([
      'ACCESS_MODE_UNSPECIFIED',
      'ACCESS_MODE_PUBLIC',
      'ACCESS_MODE_PRIVATE',
      'ACCESS_MODE_PRIVATE_ALL',
    ])
    .optional(),
  subjects: z.array(zAccessSubject).optional(),
})

export const zReportRuntimeAssignmentStatusReply = z.object({
  accepted: z.boolean().optional(),
  stale: z.boolean().optional(),
})

/**
 * RequiredSlot is an input requirement extracted from a Release's
 * DSL.
 */
export const zRequiredSlot = z.object({
  type: z
    .enum(['SLOT_TYPE_UNSPECIFIED', 'SLOT_TYPE_PLUGIN_CREDENTIAL', 'SLOT_TYPE_ENV_VAR'])
    .optional(),
  providerId: z.string().optional(),
  category: z
    .enum(['PLUGIN_CATEGORY_UNSPECIFIED', 'PLUGIN_CATEGORY_MODEL', 'PLUGIN_CATEGORY_TOOL'])
    .optional(),
  name: z.string().optional(),
})

export const zRelease = z.object({
  id: z.string().optional(),
  appInstanceId: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
  source: z
    .enum(['RELEASE_SOURCE_UNSPECIFIED', 'RELEASE_SOURCE_SOURCE_APP', 'RELEASE_SOURCE_UPLOAD'])
    .optional(),
  sourceAppId: z.string().optional(),
  gateCommitId: z.string().optional(),
  requiredSlots: z.array(zRequiredSlot).optional(),
  createdBy: zActor.optional(),
  createdAt: z.string().optional(),
})

export const zCreateReleaseReply = z.object({
  release: zRelease.optional(),
  appInstance: zAppInstance.optional(),
})

export const zDeployment = z.object({
  id: z.string().optional(),
  status: z
    .enum([
      'DEPLOYMENT_STATUS_UNSPECIFIED',
      'DEPLOYMENT_STATUS_DEPLOYING',
      'DEPLOYMENT_STATUS_READY',
      'DEPLOYMENT_STATUS_FAILED',
      'DEPLOYMENT_STATUS_CANCELLED',
    ])
    .optional(),
  environment: zEnvironment.optional(),
  release: zRelease.optional(),
  error: zError.optional(),
  createdAt: z.string().optional(),
  finalizedAt: z.string().optional(),
})

export const zCreateInitialDeploymentReply = z.object({
  appInstance: zAppInstance.optional(),
  release: zRelease.optional(),
  deployment: zDeployment.optional(),
})

export const zDeploymentReply = z.object({
  deployment: zDeployment.optional(),
})

export const zEnvironmentDeployment = z.object({
  appInstanceId: z.string().optional(),
  environment: zEnvironment.optional(),
  status: z
    .enum([
      'RUNTIME_INSTANCE_STATUS_UNSPECIFIED',
      'RUNTIME_INSTANCE_STATUS_UNDEPLOYED',
      'RUNTIME_INSTANCE_STATUS_DEPLOYING',
      'RUNTIME_INSTANCE_STATUS_READY',
      'RUNTIME_INSTANCE_STATUS_FAILED',
      'RUNTIME_INSTANCE_STATUS_DRIFTED',
      'RUNTIME_INSTANCE_STATUS_INVALID',
    ])
    .optional(),
  currentRelease: zRelease.optional(),
  desiredRelease: zRelease.optional(),
  currentDeployment: zEnvironmentDeploymentRecord.optional(),
  error: zError.optional(),
  updatedAt: z.string().optional(),
})

export const zGetReleaseReply = z.object({
  release: zRelease.optional(),
})

export const zListEnvironmentDeploymentsReply = z.object({
  data: z.array(zEnvironmentDeployment).optional(),
})

export const zResolveApiTokenRouteReply = z.object({
  environmentId: z.string().optional(),
  namespace: z.string().optional(),
  serviceName: z.string().optional(),
  servicePort: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  environmentStatus: z.string().optional(),
  appId: z.string().optional(),
  tenantId: z.string().optional(),
  runtimeInstanceId: z.string().optional(),
  observedReleaseId: z.string().optional(),
  runtimeInstanceStatus: z.string().optional(),
  revoked: z.boolean().optional(),
  unavailableReason: z.string().optional(),
  targetKind: z.string().optional(),
  directUpstream: z.string().optional(),
})

export const zResolveApiTokenRouteReq = z.object({
  token: z.string().optional(),
})

export const zRollbackReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  idempotencyKey: z.string().optional(),
})

export const zRunnerInfo = z.object({
  hostname: z.string().optional(),
})

export const zBootstrapRunnerReq = z.object({
  runner: zRunnerInfo.optional(),
})

export const zRuntimeArtifact = z.object({
  dslYaml: z.string().optional(),
  bindingSnapshotVersion: z.string().optional(),
  bindingSnapshot: z.record(z.string(), z.unknown()).optional(),
})

export const zRuntimeArtifactRequest = z.object({
  runtimeInstanceId: z.string().optional(),
  releaseId: z.string().optional(),
  deploymentId: z.string().optional(),
  bindingSnapshotVersion: z.string().optional(),
})

export const zBatchResolveRuntimeArtifactsReq = z.object({
  artifacts: z.array(zRuntimeArtifactRequest).optional(),
})

export const zRuntimeArtifactResult = z.object({
  runtimeInstanceId: z.string().optional(),
  releaseId: z.string().optional(),
  artifact: zRuntimeArtifact.optional(),
  errorCode: z.string().optional(),
  errorMessage: z.string().optional(),
  deploymentId: z.string().optional(),
})

export const zBatchResolveRuntimeArtifactsReply = z.object({
  results: z.array(zRuntimeArtifactResult).optional(),
})

/**
 * RuntimeLastError describes a failed assignment's terminal cause.
 */
export const zRuntimeLastError = z.object({
  phase: z.string().optional(),
  code: z.string().optional(),
  message: z.string().optional(),
  releaseId: z.string().optional(),
})

export const zReportRuntimeAssignmentStatusReq = z.object({
  deploymentId: z.string().optional(),
  runtimeInstanceId: z.string().optional(),
  releaseId: z.string().optional(),
  status: z.string().optional(),
  lastError: zRuntimeLastError.optional(),
  runnerId: z.string().optional(),
  assignmentRevision: z.string().optional(),
})

export const zTokenExchangeReply = z.object({
  accessToken: z.string().optional(),
  expiresAt: z.iso.datetime().optional(),
})

export const zTokenExchangeReq = z.object({
  joinToken: z.string().optional(),
})

export const zUndeployReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  idempotencyKey: z.string().optional(),
})

export const zUpdateAccessChannelsReply = z.object({
  accessChannels: zAccessChannels.optional(),
})

export const zUpdateAccessChannelsReq = z.object({
  appInstanceId: z.string().optional(),
  webAppEnabled: z.boolean().optional(),
  developerApiEnabled: z.boolean().optional(),
})

export const zUpdateAppInstanceReply = z.object({
  appInstance: zAppInstance.optional(),
})

export const zUpdateAppInstanceReq = z.object({
  appInstanceId: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
})

export const zUpdateReleaseReply = z.object({
  release: zRelease.optional(),
})

export const zUpdateReleaseReq = z.object({
  releaseId: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
})

/**
 * CursorPagination: pagination by cursor token
 */
export const zCursorPagination = z.object({
  pageSize: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  nextCursor: z.string().optional(),
  prevCursor: z.string().optional(),
  hasNextPage: z.boolean().optional(),
  hasPrevPage: z.boolean().optional(),
  totalCount: z.string().optional(),
})

export const zListAppRunnerLogsReply = z.object({
  data: z.array(zAppRunnerLog).optional(),
  pagination: zCursorPagination.optional(),
  lastArchived: z.iso.datetime().optional(),
})

/**
 * Pagination ： Just for pagination by page
 */
export const zPagination = z.object({
  totalCount: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  perPage: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  currentPage: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  totalPages: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
})

export const zListAppInstancesReply = z.object({
  data: z.array(zAppInstance).optional(),
  pagination: zPagination.optional(),
})

export const zListDeploymentsReply = z.object({
  data: z.array(zDeployment).optional(),
  pagination: zPagination.optional(),
})

export const zListReleasesReply = z.object({
  data: z.array(zRelease).optional(),
  pagination: zPagination.optional(),
})

export const zAccessServiceDeleteApiKeyPath = z.object({
  apiKeyId: z.string(),
})

/**
 * OK
 */
export const zAccessServiceDeleteApiKeyResponse = zDeleteApiKeyReply

export const zAppInstanceServiceListAppInstancesQuery = z.object({
  pageNumber: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  resultsPerPage: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  name: z.string().optional(),
  environmentId: z.string().optional(),
})

/**
 * OK
 */
export const zAppInstanceServiceListAppInstancesResponse = zListAppInstancesReply

export const zAppInstanceServiceCreateAppInstanceBody = zCreateAppInstanceReq

/**
 * OK
 */
export const zAppInstanceServiceCreateAppInstanceResponse = zCreateAppInstanceReply

export const zAppInstanceServiceDeleteAppInstancePath = z.object({
  appInstanceId: z.string(),
})

/**
 * OK
 */
export const zAppInstanceServiceDeleteAppInstanceResponse = zDeleteAppInstanceReply

export const zAppInstanceServiceGetAppInstancePath = z.object({
  appInstanceId: z.string(),
})

/**
 * OK
 */
export const zAppInstanceServiceGetAppInstanceResponse = zGetAppInstanceReply

export const zAppInstanceServiceUpdateAppInstanceBody = zUpdateAppInstanceReq

export const zAppInstanceServiceUpdateAppInstancePath = z.object({
  appInstanceId: z.string(),
})

/**
 * OK
 */
export const zAppInstanceServiceUpdateAppInstanceResponse = zUpdateAppInstanceReply

export const zAccessServiceGetAccessChannelsPath = z.object({
  appInstanceId: z.string(),
})

/**
 * OK
 */
export const zAccessServiceGetAccessChannelsResponse = zGetAccessChannelsReply

export const zAccessServiceUpdateAccessChannelsBody = zUpdateAccessChannelsReq

export const zAccessServiceUpdateAccessChannelsPath = z.object({
  appInstanceId: z.string(),
})

/**
 * OK
 */
export const zAccessServiceUpdateAccessChannelsResponse = zUpdateAccessChannelsReply

export const zDeploymentServiceListDeploymentsPath = z.object({
  appInstanceId: z.string(),
})

export const zDeploymentServiceListDeploymentsQuery = z.object({
  pageNumber: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  resultsPerPage: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  environmentId: z.string().optional(),
})

/**
 * OK
 */
export const zDeploymentServiceListDeploymentsResponse = zListDeploymentsReply

export const zDeploymentServiceListEnvironmentDeploymentsPath = z.object({
  appInstanceId: z.string(),
})

/**
 * OK
 */
export const zDeploymentServiceListEnvironmentDeploymentsResponse = zListEnvironmentDeploymentsReply

export const zAccessServiceGetAccessPolicyPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zAccessServiceGetAccessPolicyResponse = zGetAccessPolicyReply

export const zAccessServicePutAccessPolicyBody = zPutAccessPolicyReq

export const zAccessServicePutAccessPolicyPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zAccessServicePutAccessPolicyResponse = zPutAccessPolicyReply

export const zAccessServiceListApiKeysPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zAccessServiceListApiKeysResponse = zListApiKeysReply

export const zAccessServiceCreateApiKeyBody = zCreateApiKeyReq

export const zAccessServiceCreateApiKeyPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zAccessServiceCreateApiKeyResponse = zCreateApiKeyReply

export const zDeploymentServiceCancelDeploymentBody = zCancelDeploymentReq

export const zDeploymentServiceCancelDeploymentPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zDeploymentServiceCancelDeploymentResponse = zDeploymentReply

export const zDeploymentServiceDeployBody = zDeployReq

export const zDeploymentServiceDeployPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zDeploymentServiceDeployResponse = zDeploymentReply

export const zDeploymentServiceRollbackBody = zRollbackReq

export const zDeploymentServiceRollbackPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zDeploymentServiceRollbackResponse = zDeploymentReply

export const zDeploymentServiceUndeployBody = zUndeployReq

export const zDeploymentServiceUndeployPath = z.object({
  appInstanceId: z.string(),
  environmentId: z.string(),
})

/**
 * OK
 */
export const zDeploymentServiceUndeployResponse = zDeploymentReply

export const zDeploymentServicePromoteBody = zPromoteReq

export const zDeploymentServicePromotePath = z.object({
  appInstanceId: z.string(),
})

/**
 * OK
 */
export const zDeploymentServicePromoteResponse = zDeploymentReply

export const zReleaseServiceListReleasesPath = z.object({
  appInstanceId: z.string(),
})

export const zReleaseServiceListReleasesQuery = z.object({
  releaseId: z.string().optional(),
  name: z.string().optional(),
  pageNumber: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  resultsPerPage: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  environmentId: z.string().optional(),
})

/**
 * OK
 */
export const zReleaseServiceListReleasesResponse = zListReleasesReply

export const zEnvironmentServiceListDeployableEnvironmentsQuery = z.object({
  environmentId: z.string().optional(),
  name: z.string().optional(),
})

/**
 * OK
 */
export const zEnvironmentServiceListDeployableEnvironmentsResponse
  = zListDeployableEnvironmentsReply

export const zReleaseServiceGetDeploymentOptionsFromDslBody = zGetDeploymentOptionsFromDslReq

/**
 * OK
 */
export const zReleaseServiceGetDeploymentOptionsFromDslResponse = zGetDeploymentOptionsReply

export const zReleaseServiceGetDeploymentOptionsFromSourceAppBody
  = zGetDeploymentOptionsFromSourceAppReq

/**
 * OK
 */
export const zReleaseServiceGetDeploymentOptionsFromSourceAppResponse = zGetDeploymentOptionsReply

export const zDeploymentServiceCreateInitialDeploymentFromDslBody
  = zCreateInitialDeploymentFromDslReq

/**
 * OK
 */
export const zDeploymentServiceCreateInitialDeploymentFromDslResponse
  = zCreateInitialDeploymentReply

export const zDeploymentServiceCreateInitialDeploymentFromSourceAppBody
  = zCreateInitialDeploymentFromSourceAppReq

/**
 * OK
 */
export const zDeploymentServiceCreateInitialDeploymentFromSourceAppResponse
  = zCreateInitialDeploymentReply

export const zReleaseServiceCreateReleaseFromDslBody = zCreateReleaseFromDslReq

/**
 * OK
 */
export const zReleaseServiceCreateReleaseFromDslResponse = zCreateReleaseReply

export const zReleaseServiceCreateReleaseFromSourceAppBody = zCreateReleaseFromSourceAppReq

/**
 * OK
 */
export const zReleaseServiceCreateReleaseFromSourceAppResponse = zCreateReleaseReply

export const zReleaseServiceDeleteReleasePath = z.object({
  releaseId: z.string(),
})

/**
 * OK
 */
export const zReleaseServiceDeleteReleaseResponse = zDeleteReleaseReply

export const zReleaseServiceGetReleasePath = z.object({
  releaseId: z.string(),
})

/**
 * OK
 */
export const zReleaseServiceGetReleaseResponse = zGetReleaseReply

export const zReleaseServiceUpdateReleaseBody = zUpdateReleaseReq

export const zReleaseServiceUpdateReleasePath = z.object({
  releaseId: z.string(),
})

/**
 * OK
 */
export const zReleaseServiceUpdateReleaseResponse = zUpdateReleaseReply

export const zReleaseServiceListReleaseCredentialCandidatesPath = z.object({
  releaseId: z.string(),
})

/**
 * OK
 */
export const zReleaseServiceListReleaseCredentialCandidatesResponse
  = zListReleaseCredentialCandidatesReply
