{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-----------------------------------------------------------------
-- Autogenerated by Thrift                                     --
--                                                             --
-- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING --
-----------------------------------------------------------------

module Database.Cassandra.Thrift.Cassandra_Client(login,set_keyspace,get,get_slice,get_count,multiget_slice,multiget_count,get_range_slices,get_indexed_slices,insert,add,remove,remove_counter,batch_mutate,truncate,describe_schema_versions,describe_keyspaces,describe_cluster_name,describe_version,describe_ring,describe_partitioner,describe_snitch,describe_keyspace,describe_splits,system_add_column_family,system_drop_column_family,system_add_keyspace,system_drop_keyspace,system_update_keyspace,system_update_column_family,execute_cql_query) where
import Data.IORef
import Prelude ( Bool(..), Enum, Double, String, Maybe(..),
                 Eq, Show, Ord,
                 return, length, IO, fromIntegral, fromEnum, toEnum,
                 (&&), (||), (==), (++), ($), (-) )

import Control.Exception
import Data.ByteString.Lazy
import Data.Int
import Data.Typeable ( Typeable )
import qualified Data.Map as Map
import qualified Data.Set as Set

import Thrift


import Database.Cassandra.Thrift.Cassandra_Types
import Database.Cassandra.Thrift.Cassandra 
seqid = newIORef 0
login (ip,op) arg_auth_request = do
  send_login op arg_auth_request
  recv_login ip
send_login op arg_auth_request = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("login", M_CALL, seqn)
  write_Login_args op (Login_args{f_Login_args_auth_request=Just arg_auth_request})
  writeMessageEnd op
  tFlush (getTransport op)
recv_login ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Login_result ip
  readMessageEnd ip
  case f_Login_result_authnx res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Login_result_authzx res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
set_keyspace (ip,op) arg_keyspace = do
  send_set_keyspace op arg_keyspace
  recv_set_keyspace ip
send_set_keyspace op arg_keyspace = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("set_keyspace", M_CALL, seqn)
  write_Set_keyspace_args op (Set_keyspace_args{f_Set_keyspace_args_keyspace=Just arg_keyspace})
  writeMessageEnd op
  tFlush (getTransport op)
recv_set_keyspace ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Set_keyspace_result ip
  readMessageEnd ip
  case f_Set_keyspace_result_ire res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
get (ip,op) arg_key arg_column_path arg_consistency_level = do
  send_get op arg_key arg_column_path arg_consistency_level
  recv_get ip
send_get op arg_key arg_column_path arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("get", M_CALL, seqn)
  write_Get_args op (Get_args{f_Get_args_key=Just arg_key,f_Get_args_column_path=Just arg_column_path,f_Get_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_get ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Get_result ip
  readMessageEnd ip
  case f_Get_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Get_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_result_nfe res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "get failed: unknown result")
get_slice (ip,op) arg_key arg_column_parent arg_predicate arg_consistency_level = do
  send_get_slice op arg_key arg_column_parent arg_predicate arg_consistency_level
  recv_get_slice ip
send_get_slice op arg_key arg_column_parent arg_predicate arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("get_slice", M_CALL, seqn)
  write_Get_slice_args op (Get_slice_args{f_Get_slice_args_key=Just arg_key,f_Get_slice_args_column_parent=Just arg_column_parent,f_Get_slice_args_predicate=Just arg_predicate,f_Get_slice_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_get_slice ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Get_slice_result ip
  readMessageEnd ip
  case f_Get_slice_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Get_slice_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_slice_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_slice_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "get_slice failed: unknown result")
get_count (ip,op) arg_key arg_column_parent arg_predicate arg_consistency_level = do
  send_get_count op arg_key arg_column_parent arg_predicate arg_consistency_level
  recv_get_count ip
send_get_count op arg_key arg_column_parent arg_predicate arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("get_count", M_CALL, seqn)
  write_Get_count_args op (Get_count_args{f_Get_count_args_key=Just arg_key,f_Get_count_args_column_parent=Just arg_column_parent,f_Get_count_args_predicate=Just arg_predicate,f_Get_count_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_get_count ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Get_count_result ip
  readMessageEnd ip
  case f_Get_count_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Get_count_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_count_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_count_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "get_count failed: unknown result")
multiget_slice (ip,op) arg_keys arg_column_parent arg_predicate arg_consistency_level = do
  send_multiget_slice op arg_keys arg_column_parent arg_predicate arg_consistency_level
  recv_multiget_slice ip
send_multiget_slice op arg_keys arg_column_parent arg_predicate arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("multiget_slice", M_CALL, seqn)
  write_Multiget_slice_args op (Multiget_slice_args{f_Multiget_slice_args_keys=Just arg_keys,f_Multiget_slice_args_column_parent=Just arg_column_parent,f_Multiget_slice_args_predicate=Just arg_predicate,f_Multiget_slice_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_multiget_slice ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Multiget_slice_result ip
  readMessageEnd ip
  case f_Multiget_slice_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Multiget_slice_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Multiget_slice_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Multiget_slice_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "multiget_slice failed: unknown result")
multiget_count (ip,op) arg_keys arg_column_parent arg_predicate arg_consistency_level = do
  send_multiget_count op arg_keys arg_column_parent arg_predicate arg_consistency_level
  recv_multiget_count ip
send_multiget_count op arg_keys arg_column_parent arg_predicate arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("multiget_count", M_CALL, seqn)
  write_Multiget_count_args op (Multiget_count_args{f_Multiget_count_args_keys=Just arg_keys,f_Multiget_count_args_column_parent=Just arg_column_parent,f_Multiget_count_args_predicate=Just arg_predicate,f_Multiget_count_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_multiget_count ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Multiget_count_result ip
  readMessageEnd ip
  case f_Multiget_count_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Multiget_count_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Multiget_count_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Multiget_count_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "multiget_count failed: unknown result")
get_range_slices (ip,op) arg_column_parent arg_predicate arg_range arg_consistency_level = do
  send_get_range_slices op arg_column_parent arg_predicate arg_range arg_consistency_level
  recv_get_range_slices ip
send_get_range_slices op arg_column_parent arg_predicate arg_range arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("get_range_slices", M_CALL, seqn)
  write_Get_range_slices_args op (Get_range_slices_args{f_Get_range_slices_args_column_parent=Just arg_column_parent,f_Get_range_slices_args_predicate=Just arg_predicate,f_Get_range_slices_args_range=Just arg_range,f_Get_range_slices_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_get_range_slices ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Get_range_slices_result ip
  readMessageEnd ip
  case f_Get_range_slices_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Get_range_slices_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_range_slices_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_range_slices_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "get_range_slices failed: unknown result")
get_indexed_slices (ip,op) arg_column_parent arg_index_clause arg_column_predicate arg_consistency_level = do
  send_get_indexed_slices op arg_column_parent arg_index_clause arg_column_predicate arg_consistency_level
  recv_get_indexed_slices ip
send_get_indexed_slices op arg_column_parent arg_index_clause arg_column_predicate arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("get_indexed_slices", M_CALL, seqn)
  write_Get_indexed_slices_args op (Get_indexed_slices_args{f_Get_indexed_slices_args_column_parent=Just arg_column_parent,f_Get_indexed_slices_args_index_clause=Just arg_index_clause,f_Get_indexed_slices_args_column_predicate=Just arg_column_predicate,f_Get_indexed_slices_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_get_indexed_slices ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Get_indexed_slices_result ip
  readMessageEnd ip
  case f_Get_indexed_slices_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Get_indexed_slices_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_indexed_slices_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Get_indexed_slices_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "get_indexed_slices failed: unknown result")
insert (ip,op) arg_key arg_column_parent arg_column arg_consistency_level = do
  send_insert op arg_key arg_column_parent arg_column arg_consistency_level
  recv_insert ip
send_insert op arg_key arg_column_parent arg_column arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("insert", M_CALL, seqn)
  write_Insert_args op (Insert_args{f_Insert_args_key=Just arg_key,f_Insert_args_column_parent=Just arg_column_parent,f_Insert_args_column=Just arg_column,f_Insert_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_insert ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Insert_result ip
  readMessageEnd ip
  case f_Insert_result_ire res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Insert_result_ue res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Insert_result_te res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
add (ip,op) arg_key arg_column_parent arg_column arg_consistency_level = do
  send_add op arg_key arg_column_parent arg_column arg_consistency_level
  recv_add ip
send_add op arg_key arg_column_parent arg_column arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("add", M_CALL, seqn)
  write_Add_args op (Add_args{f_Add_args_key=Just arg_key,f_Add_args_column_parent=Just arg_column_parent,f_Add_args_column=Just arg_column,f_Add_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_add ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Add_result ip
  readMessageEnd ip
  case f_Add_result_ire res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Add_result_ue res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Add_result_te res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
remove (ip,op) arg_key arg_column_path arg_timestamp arg_consistency_level = do
  send_remove op arg_key arg_column_path arg_timestamp arg_consistency_level
  recv_remove ip
send_remove op arg_key arg_column_path arg_timestamp arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("remove", M_CALL, seqn)
  write_Remove_args op (Remove_args{f_Remove_args_key=Just arg_key,f_Remove_args_column_path=Just arg_column_path,f_Remove_args_timestamp=Just arg_timestamp,f_Remove_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_remove ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Remove_result ip
  readMessageEnd ip
  case f_Remove_result_ire res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Remove_result_ue res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Remove_result_te res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
remove_counter (ip,op) arg_key arg_path arg_consistency_level = do
  send_remove_counter op arg_key arg_path arg_consistency_level
  recv_remove_counter ip
send_remove_counter op arg_key arg_path arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("remove_counter", M_CALL, seqn)
  write_Remove_counter_args op (Remove_counter_args{f_Remove_counter_args_key=Just arg_key,f_Remove_counter_args_path=Just arg_path,f_Remove_counter_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_remove_counter ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Remove_counter_result ip
  readMessageEnd ip
  case f_Remove_counter_result_ire res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Remove_counter_result_ue res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Remove_counter_result_te res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
batch_mutate (ip,op) arg_mutation_map arg_consistency_level = do
  send_batch_mutate op arg_mutation_map arg_consistency_level
  recv_batch_mutate ip
send_batch_mutate op arg_mutation_map arg_consistency_level = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("batch_mutate", M_CALL, seqn)
  write_Batch_mutate_args op (Batch_mutate_args{f_Batch_mutate_args_mutation_map=Just arg_mutation_map,f_Batch_mutate_args_consistency_level=Just arg_consistency_level})
  writeMessageEnd op
  tFlush (getTransport op)
recv_batch_mutate ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Batch_mutate_result ip
  readMessageEnd ip
  case f_Batch_mutate_result_ire res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Batch_mutate_result_ue res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Batch_mutate_result_te res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
truncate (ip,op) arg_cfname = do
  send_truncate op arg_cfname
  recv_truncate ip
send_truncate op arg_cfname = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("truncate", M_CALL, seqn)
  write_Truncate_args op (Truncate_args{f_Truncate_args_cfname=Just arg_cfname})
  writeMessageEnd op
  tFlush (getTransport op)
recv_truncate ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Truncate_result ip
  readMessageEnd ip
  case f_Truncate_result_ire res of
    Nothing -> return ()
    Just _v -> throw _v
  case f_Truncate_result_ue res of
    Nothing -> return ()
    Just _v -> throw _v
  return ()
describe_schema_versions (ip,op) = do
  send_describe_schema_versions op
  recv_describe_schema_versions ip
send_describe_schema_versions op = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_schema_versions", M_CALL, seqn)
  write_Describe_schema_versions_args op (Describe_schema_versions_args{})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_schema_versions ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_schema_versions_result ip
  readMessageEnd ip
  case f_Describe_schema_versions_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Describe_schema_versions_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "describe_schema_versions failed: unknown result")
describe_keyspaces (ip,op) = do
  send_describe_keyspaces op
  recv_describe_keyspaces ip
send_describe_keyspaces op = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_keyspaces", M_CALL, seqn)
  write_Describe_keyspaces_args op (Describe_keyspaces_args{})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_keyspaces ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_keyspaces_result ip
  readMessageEnd ip
  case f_Describe_keyspaces_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Describe_keyspaces_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "describe_keyspaces failed: unknown result")
describe_cluster_name (ip,op) = do
  send_describe_cluster_name op
  recv_describe_cluster_name ip
send_describe_cluster_name op = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_cluster_name", M_CALL, seqn)
  write_Describe_cluster_name_args op (Describe_cluster_name_args{})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_cluster_name ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_cluster_name_result ip
  readMessageEnd ip
  case f_Describe_cluster_name_result_success res of
    Just v -> return v
    Nothing -> do
      throw (AppExn AE_MISSING_RESULT "describe_cluster_name failed: unknown result")
describe_version (ip,op) = do
  send_describe_version op
  recv_describe_version ip
send_describe_version op = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_version", M_CALL, seqn)
  write_Describe_version_args op (Describe_version_args{})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_version ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_version_result ip
  readMessageEnd ip
  case f_Describe_version_result_success res of
    Just v -> return v
    Nothing -> do
      throw (AppExn AE_MISSING_RESULT "describe_version failed: unknown result")
describe_ring (ip,op) arg_keyspace = do
  send_describe_ring op arg_keyspace
  recv_describe_ring ip
send_describe_ring op arg_keyspace = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_ring", M_CALL, seqn)
  write_Describe_ring_args op (Describe_ring_args{f_Describe_ring_args_keyspace=Just arg_keyspace})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_ring ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_ring_result ip
  readMessageEnd ip
  case f_Describe_ring_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Describe_ring_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "describe_ring failed: unknown result")
describe_partitioner (ip,op) = do
  send_describe_partitioner op
  recv_describe_partitioner ip
send_describe_partitioner op = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_partitioner", M_CALL, seqn)
  write_Describe_partitioner_args op (Describe_partitioner_args{})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_partitioner ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_partitioner_result ip
  readMessageEnd ip
  case f_Describe_partitioner_result_success res of
    Just v -> return v
    Nothing -> do
      throw (AppExn AE_MISSING_RESULT "describe_partitioner failed: unknown result")
describe_snitch (ip,op) = do
  send_describe_snitch op
  recv_describe_snitch ip
send_describe_snitch op = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_snitch", M_CALL, seqn)
  write_Describe_snitch_args op (Describe_snitch_args{})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_snitch ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_snitch_result ip
  readMessageEnd ip
  case f_Describe_snitch_result_success res of
    Just v -> return v
    Nothing -> do
      throw (AppExn AE_MISSING_RESULT "describe_snitch failed: unknown result")
describe_keyspace (ip,op) arg_keyspace = do
  send_describe_keyspace op arg_keyspace
  recv_describe_keyspace ip
send_describe_keyspace op arg_keyspace = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_keyspace", M_CALL, seqn)
  write_Describe_keyspace_args op (Describe_keyspace_args{f_Describe_keyspace_args_keyspace=Just arg_keyspace})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_keyspace ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_keyspace_result ip
  readMessageEnd ip
  case f_Describe_keyspace_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Describe_keyspace_result_nfe res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Describe_keyspace_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "describe_keyspace failed: unknown result")
describe_splits (ip,op) arg_cfName arg_start_token arg_end_token arg_keys_per_split = do
  send_describe_splits op arg_cfName arg_start_token arg_end_token arg_keys_per_split
  recv_describe_splits ip
send_describe_splits op arg_cfName arg_start_token arg_end_token arg_keys_per_split = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("describe_splits", M_CALL, seqn)
  write_Describe_splits_args op (Describe_splits_args{f_Describe_splits_args_cfName=Just arg_cfName,f_Describe_splits_args_start_token=Just arg_start_token,f_Describe_splits_args_end_token=Just arg_end_token,f_Describe_splits_args_keys_per_split=Just arg_keys_per_split})
  writeMessageEnd op
  tFlush (getTransport op)
recv_describe_splits ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Describe_splits_result ip
  readMessageEnd ip
  case f_Describe_splits_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Describe_splits_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "describe_splits failed: unknown result")
system_add_column_family (ip,op) arg_cf_def = do
  send_system_add_column_family op arg_cf_def
  recv_system_add_column_family ip
send_system_add_column_family op arg_cf_def = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("system_add_column_family", M_CALL, seqn)
  write_System_add_column_family_args op (System_add_column_family_args{f_System_add_column_family_args_cf_def=Just arg_cf_def})
  writeMessageEnd op
  tFlush (getTransport op)
recv_system_add_column_family ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_System_add_column_family_result ip
  readMessageEnd ip
  case f_System_add_column_family_result_success res of
    Just v -> return v
    Nothing -> do
      case f_System_add_column_family_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_System_add_column_family_result_sde res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "system_add_column_family failed: unknown result")
system_drop_column_family (ip,op) arg_column_family = do
  send_system_drop_column_family op arg_column_family
  recv_system_drop_column_family ip
send_system_drop_column_family op arg_column_family = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("system_drop_column_family", M_CALL, seqn)
  write_System_drop_column_family_args op (System_drop_column_family_args{f_System_drop_column_family_args_column_family=Just arg_column_family})
  writeMessageEnd op
  tFlush (getTransport op)
recv_system_drop_column_family ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_System_drop_column_family_result ip
  readMessageEnd ip
  case f_System_drop_column_family_result_success res of
    Just v -> return v
    Nothing -> do
      case f_System_drop_column_family_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_System_drop_column_family_result_sde res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "system_drop_column_family failed: unknown result")
system_add_keyspace (ip,op) arg_ks_def = do
  send_system_add_keyspace op arg_ks_def
  recv_system_add_keyspace ip
send_system_add_keyspace op arg_ks_def = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("system_add_keyspace", M_CALL, seqn)
  write_System_add_keyspace_args op (System_add_keyspace_args{f_System_add_keyspace_args_ks_def=Just arg_ks_def})
  writeMessageEnd op
  tFlush (getTransport op)
recv_system_add_keyspace ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_System_add_keyspace_result ip
  readMessageEnd ip
  case f_System_add_keyspace_result_success res of
    Just v -> return v
    Nothing -> do
      case f_System_add_keyspace_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_System_add_keyspace_result_sde res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "system_add_keyspace failed: unknown result")
system_drop_keyspace (ip,op) arg_keyspace = do
  send_system_drop_keyspace op arg_keyspace
  recv_system_drop_keyspace ip
send_system_drop_keyspace op arg_keyspace = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("system_drop_keyspace", M_CALL, seqn)
  write_System_drop_keyspace_args op (System_drop_keyspace_args{f_System_drop_keyspace_args_keyspace=Just arg_keyspace})
  writeMessageEnd op
  tFlush (getTransport op)
recv_system_drop_keyspace ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_System_drop_keyspace_result ip
  readMessageEnd ip
  case f_System_drop_keyspace_result_success res of
    Just v -> return v
    Nothing -> do
      case f_System_drop_keyspace_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_System_drop_keyspace_result_sde res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "system_drop_keyspace failed: unknown result")
system_update_keyspace (ip,op) arg_ks_def = do
  send_system_update_keyspace op arg_ks_def
  recv_system_update_keyspace ip
send_system_update_keyspace op arg_ks_def = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("system_update_keyspace", M_CALL, seqn)
  write_System_update_keyspace_args op (System_update_keyspace_args{f_System_update_keyspace_args_ks_def=Just arg_ks_def})
  writeMessageEnd op
  tFlush (getTransport op)
recv_system_update_keyspace ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_System_update_keyspace_result ip
  readMessageEnd ip
  case f_System_update_keyspace_result_success res of
    Just v -> return v
    Nothing -> do
      case f_System_update_keyspace_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_System_update_keyspace_result_sde res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "system_update_keyspace failed: unknown result")
system_update_column_family (ip,op) arg_cf_def = do
  send_system_update_column_family op arg_cf_def
  recv_system_update_column_family ip
send_system_update_column_family op arg_cf_def = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("system_update_column_family", M_CALL, seqn)
  write_System_update_column_family_args op (System_update_column_family_args{f_System_update_column_family_args_cf_def=Just arg_cf_def})
  writeMessageEnd op
  tFlush (getTransport op)
recv_system_update_column_family ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_System_update_column_family_result ip
  readMessageEnd ip
  case f_System_update_column_family_result_success res of
    Just v -> return v
    Nothing -> do
      case f_System_update_column_family_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_System_update_column_family_result_sde res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "system_update_column_family failed: unknown result")
execute_cql_query (ip,op) arg_query arg_compression = do
  send_execute_cql_query op arg_query arg_compression
  recv_execute_cql_query ip
send_execute_cql_query op arg_query arg_compression = do
  seq <- seqid
  seqn <- readIORef seq
  writeMessageBegin op ("execute_cql_query", M_CALL, seqn)
  write_Execute_cql_query_args op (Execute_cql_query_args{f_Execute_cql_query_args_query=Just arg_query,f_Execute_cql_query_args_compression=Just arg_compression})
  writeMessageEnd op
  tFlush (getTransport op)
recv_execute_cql_query ip = do
  (fname, mtype, rseqid) <- readMessageBegin ip
  if mtype == M_EXCEPTION then do
    x <- readAppExn ip
    readMessageEnd ip
    throw x
    else return ()
  res <- read_Execute_cql_query_result ip
  readMessageEnd ip
  case f_Execute_cql_query_result_success res of
    Just v -> return v
    Nothing -> do
      case f_Execute_cql_query_result_ire res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Execute_cql_query_result_ue res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Execute_cql_query_result_te res of
        Nothing -> return ()
        Just _v -> throw _v
      case f_Execute_cql_query_result_sde res of
        Nothing -> return ()
        Just _v -> throw _v
      throw (AppExn AE_MISSING_RESULT "execute_cql_query failed: unknown result")