'use server'
import {callByUser, callPublic} from '@/actions/base'
import {Channel} from '@/lib/models'
import {PageRecord} from '@/lib/api'

export async function listChannels(props: {
  page: number
  size: number
  auth_type?: number
  prov?: string
  city?: string
  isp?: string
  expiration?: Date
}) {
  return callByUser<PageRecord<Channel>>('/api/channel/list', props)
}

type CreateChannelsResp = {
  host: string
  port: string
  username?: string
  password?: string
}

export async function createChannels(params: {
  resource_id: number
  protocol: number
  auth_type: number
  count: number
  prov?: string
  city?: string
  isp?: number
}) {
  return callPublic<CreateChannelsResp[]>('/api/channel/create', params)
}
