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

import * as z from 'zod'

export const zAccessModeOption = z.object({
  mode: z.string().optional(),
  label: z.string().optional(),
  disabled: z.boolean().optional(),
  selected: z.boolean().optional(),
})

export const zAccessStatus = z.object({
  accessChannelsEnabled: z.boolean().optional(),
  webappUrl: z.string().optional(),
  cliUrl: z.string().optional(),
  developerApiEnabled: z.boolean().optional(),
  apiKeyCount: 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 zAccessSubject = z.object({
  subjectId: z.string().optional(),
  subjectType: z.string().optional(),
})

export const zAccessSubjectDisplay = z.object({
  id: z.string().optional(),
  subjectType: z.string().optional(),
  name: z.string().optional(),
  avatarUrl: z.string().optional(),
  memberCount: z.string().optional(),
})

export const zAccessPolicyDetail = z.object({
  accessMode: z.string().optional(),
  subjects: z.array(zAccessSubjectDisplay).optional(),
  options: z.array(zAccessModeOption).optional(),
})

/**
 * Account represents a basic user account
 */
export const zAccount = z.object({
  id: z.string().optional(),
  email: z.string().optional(),
  name: z.string().optional(),
})

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

/**
 * AccountInWorkspace represents account's role in a workspace
 */
export const zAccountInWorkspace = z.object({
  workspaceId: z.string().optional(),
  workspaceName: z.string().optional(),
  role: z.string().optional(),
})

/**
 * AccountDetail contains detailed account information
 */
export const zAccountDetail = z.object({
  account: zAccount.optional(),
  status: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
  lastActiveAt: z.iso.datetime().optional(),
  workspaces: z.array(zAccountInWorkspace).optional(),
  groups: z.array(zAccountDetailGroup).optional(),
})

export const zAckDeploymentReply = z.object({
  accepted: z.boolean().optional(),
  newVersion: z.string().optional(),
})

export const zAppInstanceBasicInfo = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
  sourceAppId: z.string().optional(),
  sourceAppName: z.string().optional(),
  mode: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
})

export const zAppRunnerBootstrapAssignment = z.object({
  appId: z.string().optional(),
  environmentId: z.string().optional(),
  workflowId: z.string().optional(),
  instanceId: z.string().optional(),
  workspaceId: z.string().optional(),
  instanceVersion: z.string().optional(),
  bindingSnapshotVersion: z.string().optional(),
  executionTokenVersion: z.string().optional(),
  executionToken: z.string().optional(),
  releaseId: z.string().optional(),
})

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

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

export const zAppRunnerBootstrapRequest = z.object({
  runner: zAppRunnerRunnerInfo.optional(),
})

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

export const zAppRunnerRuntimeArtifactRequest = z.object({
  instanceId: z.string().optional(),
  releaseId: z.string().optional(),
  bindingSnapshotVersion: z.string().optional(),
})

export const zAppRunnerBatchRuntimeArtifactRequest = z.object({
  artifacts: z.array(zAppRunnerRuntimeArtifactRequest).optional(),
})

export const zAppRunnerRuntimeArtifactResult = z.object({
  instanceId: z.string().optional(),
  releaseId: z.string().optional(),
  artifact: zAppRunnerRuntimeArtifactReply.optional(),
  errorCode: z.string().optional(),
  errorMessage: z.string().optional(),
})

export const zAppRunnerBatchRuntimeArtifactReply = z.object({
  results: z.array(zAppRunnerRuntimeArtifactResult).optional(),
})

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

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

/**
 * BootstrapProgress is step-list-agnostic. Reconcilers emit step names as
 * strings owned by each executor (e.g. "connectivity", "namespace"), so adding
 * or removing steps does not break the API.
 */
export const zBootstrapProgress = z.object({
  currentStep: z.string().optional(),
  completedSteps: z.array(z.string()).optional(),
  attemptCount: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  lastAttemptAt: z.iso.datetime().optional(),
  lastErrorCode: z.string().optional(),
  lastErrorMessage: z.string().optional(),
})

export const zBrandingInfo = z.object({
  enabled: z.boolean().optional(),
  applicationTitle: z.string().optional(),
  loginPageLogo: z.string().optional(),
  workspaceLogo: z.string().optional(),
  favicon: z.string().optional(),
})

export const zCancelRuntimeDeploymentReply = z.object({
  status: z.string().optional(),
})

export const zCancelRuntimeDeploymentReq = z.object({
  appInstanceId: z.string().optional(),
  runtimeInstanceId: z.string().optional(),
})

export const zCheckPasswordStatusReply = z.object({
  requirePasswordChange: z.boolean().optional(),
  changeReason: z.int().optional(),
  daysToExpire: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  message: z.string().optional(),
})

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

export const zCliAccess = z.object({
  url: z.string().optional(),
})

export const zConsoleEnvironment = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  runtime: z.string().optional(),
  type: z.string().optional(),
  status: z.string().optional(),
})

export const zConsoleRelease = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  shortCommitId: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
})

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

export const zCreateAppInstanceReply = z.object({
  appInstanceId: z.string().optional(),
  initialRelease: zConsoleRelease.optional(),
})

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

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

export const zCreateDeploymentReply = z.object({
  runtimeInstanceId: z.string().optional(),
  deploymentId: z.string().optional(),
  status: z.string().optional(),
})

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

export const zCreateMemberReply = z.object({
  id: z.string().optional(),
  password: z.string().optional(),
})

/**
 * Create member messages
 */
export const zCreateMemberReq = z.object({
  name: z.string().optional(),
  email: z.string().optional(),
  status: z.string().optional(),
})

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

export const zCreateNewGroupsReq = z.object({
  groups: z.array(zCreateNewGroupsReqGroup).optional(),
})

export const zCreateReleaseReply = z.object({
  release: zConsoleRelease.optional(),
})

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

export const zCreateSecretKeyReply = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  secretKey: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
  lastActive: z.iso.datetime().optional(),
})

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

export const zCreateUserReply = z.object({
  id: z.string().optional(),
  password: z.string().optional(),
})

export const zCreateUserReq = z.object({
  name: z.string().optional(),
  email: z.string().optional(),
  status: z.string().optional(),
})

/**
 * Create workspace messages
 */
export const zCreateWorkspaceReq = z.object({
  name: z.string().optional(),
  email: z.string().optional(),
  status: z.string().optional(),
})

export const zCurrentUserReply = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  email: z.string().optional(),
  interfaceLanguage: z.string().optional(),
  timezone: z.string().optional(),
})

export const zDashboardSsooidcLoginReply = z.object({
  url: z.string().optional(),
  state: z.string().optional(),
})

export const zDashboardSsoOauth2LoginReply = z.object({
  url: z.string().optional(),
  state: z.string().optional(),
})

/**
 * Dashboard SSO Login messages
 */
export const zDashboardSsosamlLoginReply = z.object({
  url: z.string().optional(),
})

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

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

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

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

export const zDeleteGuard = z.object({
  canDelete: z.boolean().optional(),
  disabledReason: z.string().optional(),
})

export const zDeleteMemberReply = z.object({
  account: zAccount.optional(),
})

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

export const zDeleteUserReply = z.object({
  account: zAccount.optional(),
})

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

export const zDeployedEnvironment = z.object({
  environmentId: z.string().optional(),
  environmentName: z.string().optional(),
})

export const zDeploymentCredentialOption = z.object({
  credentialId: z.string().optional(),
  displayName: z.string().optional(),
  pluginId: z.string().optional(),
  pluginName: z.string().optional(),
  pluginVersion: z.string().optional(),
})

export const zDeploymentEnvVarOption = z.object({
  envVarId: z.string().optional(),
  name: z.string().optional(),
  valueType: z.string().optional(),
  displayValue: z.string().optional(),
})

export const zDeploymentBindingOptionSlot = z.object({
  slot: z.string().optional(),
  kind: z.string().optional(),
  label: z.string().optional(),
  required: z.boolean().optional(),
  candidates: z.array(zDeploymentCredentialOption).optional(),
  envVarCandidates: z.array(zDeploymentEnvVarOption).optional(),
})

export const zDeploymentEnvironmentOption = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  type: z.string().optional(),
  backend: z.string().optional(),
  status: z.string().optional(),
  managedBy: z.string().optional(),
  deployable: z.boolean().optional(),
  disabledReason: z.string().optional(),
})

export const zDeploymentRuntimeBinding = z.object({
  slot: z.string().optional(),
  credentialId: z.string().optional(),
  envVarId: z.string().optional(),
})

export const zCreateDeploymentReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  releaseId: z.string().optional(),
  bindings: z.array(zDeploymentRuntimeBinding).optional(),
})

export const zDeploymentStatusRow = z.object({
  environment: zConsoleEnvironment.optional(),
  release: zConsoleRelease.optional(),
  status: z.string().optional(),
})

export const zDeveloperApiKeyRow = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  environment: zConsoleEnvironment.optional(),
  maskedKey: z.string().optional(),
})

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

export const zDeveloperApiAccess = z.object({
  enabled: z.boolean().optional(),
  apiKeys: z.array(zDeveloperApiKeyRow).optional(),
})

/**
 * System user setting messages
 */
export const zEnterpriseSystemUserSettingReply = z.object({
  ssoEnforcedForSignin: z.boolean().optional(),
  ssoEnforcedForSigninProtocol: z.string().optional(),
  enableEmailPasswordLogin: z.boolean().optional(),
})

export const zEnvironment = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  description: z.string().optional(),
  mode: z.int().optional(),
  namespace: z.string().optional(),
  apiServer: z.string().optional(),
  status: z.int().optional(),
  statusMessage: z.string().optional(),
  bootstrapProgress: zBootstrapProgress.optional(),
  managedBy: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
  updatedAt: z.iso.datetime().optional(),
  backend: z.int().optional(),
  host: z.string().optional(),
})

export const zCreateEnvironmentReply = z.object({
  environment: zEnvironment.optional(),
})

export const zEnvironmentAccessRow = z.object({
  environment: zConsoleEnvironment.optional(),
  currentRelease: zConsoleRelease.optional(),
  accessMode: z.string().optional(),
  accessModeLabel: z.string().optional(),
  hint: z.string().optional(),
})

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

export const zGetAppInstanceOverviewReply = z.object({
  instance: zAppInstanceBasicInfo.optional(),
  deployments: z.array(zDeploymentStatusRow).optional(),
  access: zAccessStatus.optional(),
})

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

export const zGetBearerTokenResponse = z.object({
  maskedToken: z.string().optional(),
})

export const zGetClusterInfoReply = z.object({
  mode: z.string().optional(),
  clusterId: z.string().optional(),
  verifyMode: z.string().optional(),
})

export const zGetEnvironmentAccessPolicyReply = z.object({
  policy: zAccessPolicyDetail.optional(),
})

export const zGetEnvironmentReply = z.object({
  environment: zEnvironment.optional(),
})

export const zGetInstanceReply = z.object({
  instanceId: z.string().optional(),
  status: z.string().optional(),
  desiredReleaseId: z.string().optional(),
  observedReleaseId: z.string().optional(),
  currentDeploymentId: z.string().optional(),
  version: z.string().optional(),
})

export const zGetLicenseStatusReply = z.object({
  status: z.string().optional(),
})

export const zGetMfaInfoReply = z.object({
  userEnabled: z.boolean().optional(),
  userSetup: z.boolean().optional(),
  globalEnabled: z.boolean().optional(),
})

export const zGetMemberReply = z.object({
  account: zAccountDetail.optional(),
})

export const zGetUserReply = z.object({
  account: zAccountDetail.optional(),
})

export const zGetWebAppAccessModeRes = z.object({
  accessMode: z.string().optional(),
})

export const zGetWebAppAuthInfoRes = z.object({
  allowSso: z.boolean().optional(),
  allowEmailCodeLogin: z.boolean().optional(),
  allowEmailPasswordLogin: z.boolean().optional(),
})

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

export const zHealthzReply = z.object({
  message: z.string().optional(),
  status: z.string().optional(),
})

export const zHostEnvironmentConfig = z.object({
  machineId: z.string().optional(),
  joinTokenHash: z.string().optional(),
})

export const zInnerBatchGetWebAppAccessModesByIdReq = z.object({
  appIds: z.array(z.string()).optional(),
})

export const zInnerBatchGetWebAppAccessModesByIdRes = z.object({
  accessModes: z.record(z.string(), z.string()).optional(),
})

export const zInnerBatchIsUserAllowedToAccessWebAppReq = z.object({
  userId: z.string().optional(),
  appIds: z.array(z.string()).optional(),
})

export const zInnerBatchIsUserAllowedToAccessWebAppRes = z.object({
  permissions: z.record(z.string(), z.boolean()).optional(),
})

export const zInnerCheckAppDeployAccessReply = z.object({
  allowed: z.boolean().optional(),
  matchedPolicyId: z.string().optional(),
  matchedScopeType: z.string().optional(),
  reason: z.string().optional(),
  cacheTtlSeconds: 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 zInnerCheckAppDeployAccessReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  principalType: z.string().optional(),
  principalId: z.string().optional(),
})

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

export const zInnerGetTokenRouteReply = 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(),
  instanceId: z.string().optional(),
  observedReleaseId: z.string().optional(),
  instanceStatus: z.string().optional(),
})

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

export const zInnerGetWebAppAccessModeByCodeRes = z.object({
  accessMode: z.string().optional(),
})

export const zInnerGetWebAppAccessModeByIdRes = z.object({
  accessMode: z.string().optional(),
})

export const zInnerIsUserAllowedToAccessWebAppRes = z.object({
  result: z.boolean().optional(),
})

export const zInnerTryAddAccountToDefaultWorkspaceReply = z.object({
  workspaceId: z.string().optional(),
  joined: z.boolean().optional(),
  message: z.string().optional(),
})

/**
 * Inner API messages
 */
export const zInnerTryAddAccountToDefaultWorkspaceReq = z.object({
  accountId: z.string().optional(),
})

export const zIsUserAllowedToAccessWebAppRes = z.object({
  result: z.boolean().optional(),
})

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

/**
 * Join workspace messages
 */
export const zJoinWorkspaceReq = z.object({
  id: z.string().optional(),
  email: z.string().optional(),
  role: z.string().optional(),
})

export const zK8sEnvironmentConfig = z.object({
  namespace: z.string().optional(),
  apiServer: z.string().optional(),
  caBundle: z.string().optional(),
  bearerToken: z.string().optional(),
})

/**
 * Field-level validation only; target (api_server) and RBAC validation happen
 * in the bootstrap reconciler.
 */
export const zCreateEnvironmentReq = z.object({
  name: z.string().optional(),
  description: z.string().optional(),
  mode: z.int().optional(),
  backend: z.int().optional(),
  k8s: zK8sEnvironmentConfig.optional(),
  host: zHostEnvironmentConfig.optional(),
})

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

export const zAckDeploymentReq = z.object({
  deploymentId: z.string().optional(),
  instanceId: z.string().optional(),
  expectedVersion: z.string().optional(),
  status: z.string().optional(),
  observedReleaseId: z.string().optional(),
  lastError: zLastError.optional(),
})

export const zListDeploymentBindingOptionsReply = z.object({
  slots: z.array(zDeploymentBindingOptionSlot).optional(),
})

export const zListDeploymentEnvironmentOptionsReply = z.object({
  environments: z.array(zDeploymentEnvironmentOption).optional(),
})

export const zLoginTypesReply = z.object({
  enabledEmailCodeLogin: z.boolean().optional(),
  enableEmailPasswordLogin: z.boolean().optional(),
  isAllowRegister: z.boolean().optional(),
  isAllowCreateWorkspace: z.boolean().optional(),
})

export const zLoginTypesReq = z.object({
  enabledEmailCodeLogin: z.boolean().optional(),
  enableEmailPasswordLogin: z.boolean().optional(),
  isAllowRegister: z.boolean().optional(),
  isAllowCreateWorkspace: z.boolean().optional(),
})

export const zMfaBackupCodesRes = z.object({
  codes: z.array(z.string()).optional(),
  validCounts: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  createdAt: z.iso.datetime().optional(),
})

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

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

export const zMfaDownloadBackupCodesSummaryRes = z.object({
  content: z.string().optional(),
})

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

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

export const zMfaGetEnrollInfoRes = z.object({
  qrCode: z.string().optional(),
  secret: z.string().optional(),
})

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

export const zOAuth2Config = z.object({
  clientId: z.string().optional(),
  clientSecret: z.string().optional(),
  authUrl: z.string().optional(),
  tokenUrl: z.string().optional(),
  userinfoUrl: z.string().optional(),
  scopes: z.string().optional(),
  enablePkce: z.boolean().optional(),
})

export const zOAuth2LoginReply = z.object({
  url: z.string().optional(),
  state: z.string().optional(),
})

export const zOidcConfig = z.object({
  issuerUrl: z.string().optional(),
  clientId: z.string().optional(),
  clientSecret: z.string().optional(),
  enablePkce: z.boolean().optional(),
})

export const zOidcReply = z.object({
  url: z.string().optional(),
  state: z.string().optional(),
})

export const zOtelExporterEndpoint = z.object({
  endpoint: z.string().optional(),
  compression: z.string().optional(),
  protocol: z.int().optional(),
  timeout: z
    .string()
    .regex(/^-?(?:0|[1-9]\d{0,11})(?:\.\d{1,9})?s$/)
    .optional(),
  headers: z.record(z.string(), z.string()).optional(),
  tlsCaPem: z.string().optional(),
  tlsInsecure: z.boolean().optional(),
  tlsClientCertPem: z.string().optional(),
  tlsClientKeyPem: z.string().optional(),
  enabled: z.boolean().optional(),
  tlsInsecureSkipVerify: z.boolean().optional(),
})

export const zEndpointReply = z.object({
  mode: z.int().optional(),
  metricsEndpoint: zOtelExporterEndpoint.optional(),
  tracesEndpoint: zOtelExporterEndpoint.optional(),
})

export const zOtelExporterStatusReply = z.object({
  connectedAt: z.iso.datetime().optional(),
  bytesPushed: z.string().optional(),
  itemsInQueue: z.string().optional(),
  logs: z.string().optional(),
  status: z.int().optional(),
})

export const zPasswordPolicyConfig = z.object({
  minLength: z
    .int()
    .min(0, { error: 'Invalid value: Expected uint32 to be >= 0' })
    .max(4294967295, { error: 'Invalid value: Expected uint32 to be <= 4294967295' })
    .optional(),
  requireDigit: z.boolean().optional(),
  requireLowercase: z.boolean().optional(),
  requireUppercase: z.boolean().optional(),
  requireSpecial: z.boolean().optional(),
  forbidRepeated: z.boolean().optional(),
  forbidSequential: z.boolean().optional(),
  expiryEnabled: z.boolean().optional(),
  expiryDays: z
    .int()
    .min(0, { error: 'Invalid value: Expected uint32 to be >= 0' })
    .max(4294967295, { error: 'Invalid value: Expected uint32 to be <= 4294967295' })
    .optional(),
})

export const zPasswordStrengthReply = z.object({
  level: z.int().optional(),
})

export const zPasswordStrengthReq = z.object({
  password: z.string().optional(),
})

export const zPluginInstallationPermissionInfo = z.object({
  pluginInstallationScope: z.string().optional(),
  restrictToMarketplaceOnly: z.boolean().optional(),
})

export const zPluginInstallationSettingsReply = z.object({
  pluginInstallationScope: z.int().optional(),
  restrictToMarketplaceOnly: z.boolean().optional(),
})

export const zPreviewReleaseReq = z.object({
  appInstanceId: z.string().optional(),
  releaseId: z.string().optional(),
})

export const zReleaseRow = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
  createdBy: zConsoleUser.optional(),
  deployedTo: z.array(zDeployedEnvironment).optional(),
})

export const zReleaseRuntimeBinding = z.object({
  kind: z.string().optional(),
  label: z.string().optional(),
  displayValue: z.string().optional(),
  valueType: z.string().optional(),
})

export const zPreviewReleaseReply = z.object({
  release: zConsoleRelease.optional(),
  bindings: z.array(zReleaseRuntimeBinding).optional(),
})

export const zResetMemberPasswordReply = z.object({
  id: z.string().optional(),
  password: z.string().optional(),
})

/**
 * Reset member password messages
 */
export const zResetMemberPasswordReq = z.object({
  id: z.string().optional(),
})

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

/**
 * Password reset messages
 */
export const zResetPasswordReq = z.object({
  currentPassword: z.string().optional(),
  newPassword: z.string().optional(),
  confirmPassword: z.string().optional(),
})

export const zResetUserPasswordReply = z.object({
  id: z.string().optional(),
  password: z.string().optional(),
})

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

export const zResolveCredentialsReq = z.object({
  instanceId: z.string().optional(),
  deploymentId: z.string().optional(),
  slots: z.array(z.string()).optional(),
})

/**
 * Exactly one of credential_id / env_var_id is populated; model/plugin slots
 * carry credential_id (pool A), env_var slots carry env_var_id (pool B).
 * See design §4.1.
 */
export const zResolvedCredential = z.object({
  slot: z.string().optional(),
  credentialId: z.string().optional(),
  envVarId: z.string().optional(),
  value: z.string().optional(),
})

export const zResolveCredentialsReply = z.object({
  resolved: z.array(zResolvedCredential).optional(),
})

/**
 * ResourceQuota represents usage quota for a resource
 */
export const zResourceQuota = z.object({
  used: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  limit: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  enabled: z.boolean().optional(),
})

export const zLicenseStatus = z.object({
  status: z.string().optional(),
  expiredAt: z.string().optional(),
  workspaces: zResourceQuota.optional(),
})

export const zLimitFields = z.object({
  workspaceMembers: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  workspaces: zResourceQuota.optional(),
})

/**
 * License information
 */
export const zLicenseInfo = z.object({
  uuid: z.string().optional(),
  expiredAt: z.iso.datetime().optional(),
  clusterId: z.string().optional(),
  product: z.string().optional(),
  limits: zLimitFields.optional(),
})

/**
 * License RPC messages
 */
export const zGetLicenseReply = z.object({
  license: zLicenseInfo.optional(),
})

export const zRetryEnvironmentReply = z.object({
  environment: zEnvironment.optional(),
})

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

export const zRuntimeEndpoints = z.object({
  run: z.string().optional(),
  health: z.string().optional(),
})

export const zRuntimeInstanceDetail = z.object({
  deploymentName: z.string().optional(),
  replicas: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  runtimeMode: z.string().optional(),
  runtimeNote: z.string().optional(),
  endpoints: zRuntimeEndpoints.optional(),
  bindings: z.array(zReleaseRuntimeBinding).optional(),
})

export const zRuntimeInstanceRow = z.object({
  id: z.string().optional(),
  environment: zConsoleEnvironment.optional(),
  status: z.string().optional(),
  currentRelease: zConsoleRelease.optional(),
  detail: zRuntimeInstanceDetail.optional(),
})

export const zListRuntimeInstancesReply = z.object({
  data: z.array(zRuntimeInstanceRow).optional(),
})

/**
 * SSO Configuration messages
 */
export const zSamlConfig = z.object({
  idpSsoUrl: z.string().optional(),
  certificate: z.string().optional(),
})

export const zSamlLoginReply = z.object({
  url: z.string().optional(),
})

export const zSsoIdPProvider = z.object({
  protocol: z.string().optional(),
  provider: z.string().optional(),
  samlConfig: zSamlConfig.optional(),
  oidcConfig: zOidcConfig.optional(),
  oauth2Config: zOAuth2Config.optional(),
})

export const zSsoSettings = z.object({
  ssoEnforced: z.boolean().optional(),
  sessionTimeout: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  ssoIdpProvider: zSsoIdPProvider.optional(),
})

export const zAuthSettingsReply = z.object({
  userSsoSettings: zSsoSettings.optional(),
  webSsoSettings: zSsoSettings.optional(),
  dashboardSsoSettings: zSsoSettings.optional(),
  userSsoSamlAcsUrl: z.string().optional(),
  userSsoOidcCallbackUrl: z.string().optional(),
  userSsoOauth2CallbackUrl: z.string().optional(),
  webSsoSamlAcsUrl: z.string().optional(),
  webSsoOidcCallbackUrl: z.string().optional(),
  webSsoOauth2CallbackUrl: z.string().optional(),
  webSsoMembersSamlAcsUrl: z.string().optional(),
  webSsoMembersOidcCallbackUrl: z.string().optional(),
  webSsoMembersOauth2CallbackUrl: z.string().optional(),
  dashboardSsoSamlAcsUrl: z.string().optional(),
  dashboardSsoOidcCallbackUrl: z.string().optional(),
  dashboardSsoOauth2CallbackUrl: z.string().optional(),
})

export const zAuthSettingsReq = z.object({
  ssoType: z.string().optional(),
  ssoSettings: zSsoSettings.optional(),
})

export const zSsoSettingsReply = z.object({
  enabled: z.boolean().optional(),
})

export const zScimSettings = z.object({
  enabled: z.boolean().optional(),
  lastSyncTime: z.iso.datetime().optional(),
})

export const zSearchAccessSubjectsReply = z.object({
  data: z.array(zAccessSubjectDisplay).optional(),
})

export const zSecretKey = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  secretKeyMasked: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
  lastActive: z.iso.datetime().optional(),
})

export const zSetDefaultWorkspaceReply = z.object({
  workspaceId: z.string().optional(),
})

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

export const zStatusCount = z.object({
  status: z.string().optional(),
  count: 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 zAppInstanceCard = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  icon: z.string().optional(),
  mode: z.string().optional(),
  sourceAppName: z.string().optional(),
  statuses: z.array(zStatusCount).optional(),
  lastDeployedAt: z.iso.datetime().optional(),
})

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

export const zSubjectGroupData = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  groupSize: 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 zCreateNewGroupsRes = z.object({
  groups: z.array(zSubjectGroupData).optional(),
})

export const zGetGroupsRes = z.object({
  groups: z.array(zSubjectGroupData).optional(),
})

export const zGetJoinedGroupsRes = z.object({
  groups: z.array(zSubjectGroupData).optional(),
})

export const zGetWebAppWhitelistSubjectsRes = z.object({
  groups: z.array(zSubjectGroupData).optional(),
  members: z.array(zGetWebAppWhitelistSubjectsResMember).optional(),
})

/**
 * Subject represents a subject (user or group) in access control
 */
export const zSubject = z.object({
  subjectId: z.string().optional(),
  subjectType: z.string().optional(),
  accountData: zSubjectAccountData.optional(),
  groupData: zSubjectGroupData.optional(),
})

export const zGetGroupSubjectsRes = z.object({
  subjects: z.array(zSubject).optional(),
})

export const zSearchForWhilteListCandidatesRes = z.object({
  subjects: z.array(zSubject).optional(),
  currPage: z
    .int()
    .min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' })
    .max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
    .optional(),
  hasMore: z.boolean().optional(),
})

export const zSystemUserSettingReply = z.object({
  isAllowRegister: z.boolean().optional(),
  enableEmailPasswordLogin: z.boolean().optional(),
})

export const zSystemUserSettingReq = z.object({
  isAllowRegister: z.boolean().optional(),
  enableEmailPasswordLogin: z.boolean().optional(),
})

export const zTestConnectionReply = z.object({
  success: z.boolean().optional(),
  error: z.string().optional(),
})

export const zTestEnvironmentConnectionReply = z.object({
  ok: z.boolean().optional(),
  reachableServerVersion: z.string().optional(),
  namespaceExists: z.boolean().optional(),
  missingPermissions: z.array(z.string()).optional(),
  error: z.string().optional(),
  probedAt: z.iso.datetime().optional(),
})

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

export const zToggleEndpointRequest = z.object({
  enabled: z.boolean().optional(),
})

export const zUndeployRuntimeInstanceReply = z.object({
  deploymentId: z.string().optional(),
  status: z.string().optional(),
})

export const zUndeployRuntimeInstanceReq = z.object({
  appInstanceId: z.string().optional(),
  runtimeInstanceId: z.string().optional(),
})

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

export const zUpdateAccessModeReq = z.object({
  appId: z.string().optional(),
  accessMode: z.string().optional(),
})

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

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

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

export const zUpdateBrandingInfoReq = z.object({
  enabled: z.boolean().optional(),
  applicationTitle: z.string().optional(),
  loginPageLogo: z.string().optional(),
  workspaceLogo: z.string().optional(),
  favicon: z.string().optional(),
})

export const zUpdateDeveloperApiReply = z.object({
  developerApi: zDeveloperApiAccess.optional(),
})

export const zUpdateDeveloperApiReq = z.object({
  appInstanceId: z.string().optional(),
  enabled: z.boolean().optional(),
})

export const zUpdateEnvironmentAccessPolicyReply = z.object({
  permission: zEnvironmentAccessRow.optional(),
})

export const zUpdateEnvironmentAccessPolicyReq = z.object({
  appInstanceId: z.string().optional(),
  environmentId: z.string().optional(),
  accessMode: z.string().optional(),
  subjects: z.array(zAccessSubject).optional(),
})

export const zUpdateEnvironmentReply = z.object({
  environment: zEnvironment.optional(),
})

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

export const zUpdateGroupSubjectsReq = z.object({
  groupId: z.string().optional(),
  subjects: z.array(zSubject).optional(),
})

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

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

export const zUpdateGroupsReq = z.object({
  groups: z.array(zUpdateGroupsReqGroup).optional(),
})

export const zUpdateGroupsRes = z.object({
  groups: z.array(zSubjectGroupData).optional(),
})

export const zUpdateJoinedGroupsReq = z.object({
  accountId: z.string().optional(),
  groupIds: z.array(z.string()).optional(),
})

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

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

export const zUpdateLicenseReq = z.object({
  licenseId: z.string().optional(),
})

export const zUpdateMfaStatusReq = z.object({
  enabled: z.boolean().optional(),
})

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

export const zUpdateMemberReply = z.object({
  account: zAccount.optional(),
})

/**
 * Update member messages
 */
export const zUpdateMemberReq = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  email: z.string().optional(),
  status: z.string().optional(),
})

export const zUpdateMembersInGroupsReq = z.object({
  groupId: z.string().optional(),
  accountIds: z.array(z.string()).optional(),
})

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

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

export const zUpdateOfflineLicenseReq = z.object({
  offlineCode: z.string().optional(),
})

export const zUpdatePluginInstallationSettingsRequest = z.object({
  pluginInstallationScope: z.int().optional(),
  restrictToMarketplaceOnly: z.boolean().optional(),
})

export const zUpdateUserReply = z.object({
  account: zAccountDetail.optional(),
})

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

/**
 * Web app auth info messages
 */
export const zUpdateWebAppAuthInfoReq = z.object({
  allowSso: z.boolean().optional(),
  allowEmailCodeLogin: z.boolean().optional(),
  allowEmailPasswordLogin: z.boolean().optional(),
})

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

export const zUpdateWebAppWhitelistSubjectsReq = z.object({
  appId: z.string().optional(),
  subjects: z.array(zSubject).optional(),
  accessMode: z.string().optional(),
})

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

/**
 * Update workspace messages
 */
export const zUpdateWorkspaceReq = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  email: z.string().optional(),
  status: z.string().optional(),
})

export const zWebAppAccessRow = z.object({
  environment: zConsoleEnvironment.optional(),
  url: z.string().optional(),
})

export const zAccessChannels = z.object({
  enabled: z.boolean().optional(),
  webappRows: z.array(zWebAppAccessRow).optional(),
  cli: zCliAccess.optional(),
})

export const zGetAppInstanceAccessReply = z.object({
  permissions: z.array(zEnvironmentAccessRow).optional(),
  accessChannels: zAccessChannels.optional(),
  developerApi: zDeveloperApiAccess.optional(),
})

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

export const zWebAppAuthInfo = z.object({
  allowSso: z.boolean().optional(),
  allowEmailCodeLogin: z.boolean().optional(),
  allowEmailPasswordLogin: z.boolean().optional(),
})

/**
 * Info configuration messages
 */
export const zInfoConfigReply = z.object({
  SSOEnforcedForSignin: z.boolean().optional(),
  SSOEnforcedForSigninProtocol: z.string().optional(),
  SSOEnforcedForWeb: z.boolean().optional(),
  SSOEnforcedForWebProtocol: z.string().optional(),
  EnableEmailCodeLogin: z.boolean().optional(),
  EnableEmailPasswordLogin: z.boolean().optional(),
  IsAllowRegister: z.boolean().optional(),
  IsAllowCreateWorkspace: z.boolean().optional(),
  License: zLicenseStatus.optional(),
  Branding: zBrandingInfo.optional(),
  WebAppAuth: zWebAppAuthInfo.optional(),
  PluginInstallationPermission: zPluginInstallationPermissionInfo.optional(),
})

export const zWebOAuth2LoginReply = z.object({
  url: z.string().optional(),
  state: z.string().optional(),
})

export const zWebOidcLoginReply = z.object({
  url: z.string().optional(),
})

export const zWebSamlLoginReply = z.object({
  url: z.string().optional(),
})

/**
 * Workspace represents a workspace entity
 */
export const zWorkspace = z.object({
  id: z.string().optional(),
  name: z.string().optional(),
  status: z.string().optional(),
  createdAt: z.iso.datetime().optional(),
  owner: zAccount.optional(),
})

export const zCreateWorkspaceReply = z.object({
  workspace: zWorkspace.optional(),
})

export const zGetDefaultWorkspaceReply = z.object({
  workspaceId: z.string().optional(),
  workspace: zWorkspace.optional(),
})

export const zGetWorkspaceReply = z.object({
  workspace: zWorkspace.optional(),
})

export const zUpdateWorkspaceReply = z.object({
  workspace: zWorkspace.optional(),
})

export const zWorkspaceInfoReply = z.object({
  WorkspaceMembers: zResourceQuota.optional(),
})

/**
 * Workspace permission
 */
export const zWorkspacePermission = z.object({
  workspaceId: z.string().optional(),
  allowMemberInvite: z.boolean().optional(),
  allowOwnerTransfer: z.boolean().optional(),
})

export const zGetWorkspacePermissionReply = z.object({
  permission: zWorkspacePermission.optional(),
})

export const zUpdateWorkspacePermissionReply = z.object({
  message: z.string().optional(),
  permission: zWorkspacePermission.optional(),
})

/**
 * Update workspace permission messages
 */
export const zUpdateWorkspacePermissionReq = z.object({
  id: z.string().optional(),
  permission: zWorkspacePermission.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({
  filters: z.array(zEnvironmentFilter).optional(),
  data: z.array(zAppInstanceCard).optional(),
  pagination: zPagination.optional(),
})

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

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

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

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

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

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

export const zEnterpriseAppDeployConsoleListAppInstancesQuery = z.object({
  environmentId: z.string().optional(),
  notDeployed: z.boolean().optional(),
  query: 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(),
})

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleListAppInstancesResponse = zListAppInstancesReply

export const zEnterpriseAppDeployConsoleCreateAppInstanceBody = zCreateAppInstanceReq

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleCreateAppInstanceResponse = zCreateAppInstanceReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleDeleteAppInstanceResponse = zDeleteAppInstanceReply

export const zEnterpriseAppDeployConsoleUpdateAppInstanceBody = zUpdateAppInstanceReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleUpdateAppInstanceResponse = zUpdateAppInstanceReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleGetAppInstanceAccessResponse = zGetAppInstanceAccessReply

export const zEnterpriseAppDeployConsoleUpdateAccessChannelsBody = zUpdateAccessChannelsReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleUpdateAccessChannelsResponse = zUpdateAccessChannelsReply

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

export const zEnterpriseAppDeployConsoleSearchAccessSubjectsQuery = z.object({
  keyword: z.string().optional(),
  subjectTypes: z.array(z.string()).optional(),
})

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleSearchAccessSubjectsResponse = zSearchAccessSubjectsReply

export const zEnterpriseAppDeployConsoleCreateDeveloperApiKeyBody = zCreateDeveloperApiKeyReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleCreateDeveloperApiKeyResponse = zCreateDeveloperApiKeyReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleDeleteDeveloperApiKeyResponse = zDeleteDeveloperApiKeyReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleListDeploymentBindingOptionsResponse
  = zListDeploymentBindingOptionsReply

export const zEnterpriseAppDeployConsoleCreateDeploymentBody = zCreateDeploymentReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleCreateDeploymentResponse = zCreateDeploymentReply

export const zEnterpriseAppDeployConsoleUpdateDeveloperApiBody = zUpdateDeveloperApiReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleUpdateDeveloperApiResponse = zUpdateDeveloperApiReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleGetEnvironmentAccessPolicyResponse
  = zGetEnvironmentAccessPolicyReply

export const zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyBody
  = zUpdateEnvironmentAccessPolicyReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleUpdateEnvironmentAccessPolicyResponse
  = zUpdateEnvironmentAccessPolicyReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleGetAppInstanceOverviewResponse
  = zGetAppInstanceOverviewReply

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

export const zEnterpriseAppDeployConsoleListReleasesQuery = 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(),
})

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleListReleasesResponse = zListReleasesReply

export const zEnterpriseAppDeployConsoleCreateReleaseBody = zCreateReleaseReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleCreateReleaseResponse = zCreateReleaseReply

export const zEnterpriseAppDeployConsolePreviewReleaseBody = zPreviewReleaseReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsolePreviewReleaseResponse = zPreviewReleaseReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleListRuntimeInstancesResponse = zListRuntimeInstancesReply

export const zEnterpriseAppDeployConsoleCancelRuntimeDeploymentBody = zCancelRuntimeDeploymentReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleCancelRuntimeDeploymentResponse
  = zCancelRuntimeDeploymentReply

export const zEnterpriseAppDeployConsoleUndeployRuntimeInstanceBody = zUndeployRuntimeInstanceReq

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleUndeployRuntimeInstanceResponse
  = zUndeployRuntimeInstanceReply

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

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleGetAppInstanceSettingsResponse
  = zGetAppInstanceSettingsReply

/**
 * OK
 */
export const zEnterpriseAppDeployConsoleListDeploymentEnvironmentOptionsResponse
  = zListDeploymentEnvironmentOptionsReply

/**
 * OK
 */
export const zConsoleSsoOAuth2LoginResponse = zOAuth2LoginReply

/**
 * OK
 */
export const zConsoleSsoOidcLoginResponse = zOidcReply

/**
 * OK
 */
export const zConsoleSsoSamlLoginResponse = zSamlLoginReply

export const zWebAppAuthGetWebAppAccessModeQuery = z.object({
  appId: z.string().optional(),
})

/**
 * OK
 */
export const zWebAppAuthGetWebAppAccessModeResponse = zGetWebAppAccessModeRes

export const zWebAppAuthUpdateWebAppWhitelistSubjectsBody = zUpdateWebAppWhitelistSubjectsReq

/**
 * OK
 */
export const zWebAppAuthUpdateWebAppWhitelistSubjectsResponse = zUpdateWebAppWhitelistSubjectsRes

export const zWebAppAuthSearchForWhilteListCandidatesQuery = z.object({
  keyword: 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(),
  groupId: z.string().optional(),
})

/**
 * OK
 */
export const zWebAppAuthSearchForWhilteListCandidatesResponse = zSearchForWhilteListCandidatesRes

export const zWebAppAuthGetWebAppWhitelistSubjectsQuery = z.object({
  appId: z.string().optional(),
})

/**
 * OK
 */
export const zWebAppAuthGetWebAppWhitelistSubjectsResponse = zGetWebAppWhitelistSubjectsRes

export const zWebAppAuthGetGroupSubjectsQuery = z.object({
  groupId: z.string().optional(),
})

/**
 * OK
 */
export const zWebAppAuthGetGroupSubjectsResponse = zGetGroupSubjectsRes

export const zWebAppAuthIsUserAllowedToAccessWebAppQuery = z.object({
  appId: z.string().optional(),
})

/**
 * OK
 */
export const zWebAppAuthIsUserAllowedToAccessWebAppResponse = zIsUserAllowedToAccessWebAppRes
