text stringlengths 0 601k |
|---|
type props = { n_val : int option |
type index_search = { keys : string list |
let parse_mc s = let bits = Bitstring . bitstring_of_string s in let module Int32 = Old_int32 in let module Char = Old_char in let module String = Old_string in let open Result . Monad_infix in bitmatch bits with | { mc : 8 ; payload : - 1 : bitstring } -> Ok ( Core . Std . Char . of_int_exn mc , payload ) | { _ } -> E... |
let run mc mc_payload f = let open Result . Monad_infix in parse_mc mc_payload >>= function | ( p_mc , payload ) when p_mc = mc -> begin P . State . create payload >>= fun s -> P . run f s >>= fun ( r , _ ) -> Ok r end | _ -> Error ` Bad_payload |
let error payload = failwith " nyi " |
let ping = function | " \ x02 " -> Ok ( Done ( ) ) | _ -> Error ` Bad_payload |
let client_id payload = let open Result . Monad_infix in run ' \ x04 ' payload Pb_response . client_id >>= fun client_id -> Ok ( Done client_id ) |
let server_info payload = let open Result . Monad_infix in run ' \ x08 ' payload Pb_response . server_info >>= fun server_info -> Ok ( Done server_info ) |
let list_buckets payload = let open Result . Monad_infix in run ' \ x10 ' payload Pb_response . list_buckets >>= fun buckets -> Ok ( Done buckets ) |
let list_keys payload = let open Result . Monad_infix in run ' \ x12 ' payload Pb_response . list_keys >>= function | ( keys , false ) -> Ok ( More keys ) | ( keys , true ) -> Ok ( Done keys ) |
let bucket_props payload = let open Result . Monad_infix in run ' \ x14 ' payload Pb_response . bucket_props >>= fun ( n_val , allow_mult ) -> match n_val with | Some n_val32 -> begin match Int32 . to_int n_val32 with end | None -> Ok ( Done { n_val = None ; allow_mult } ) |
let get payload = let open Result . Monad_infix in run ' \ x0A ' payload Pb_response . get >>= fun ( c , vclock , unchanged ) -> Ok ( Done ( Robj . of_pb c vclock unchanged ) ) |
let put payload = let open Result . Monad_infix in run ' \ x0C ' payload Pb_response . put >>= fun ( c , vclock , key ) -> Ok ( Done ( Robj . of_pb c vclock None , key ) ) |
let delete = function | " \ x0E " -> Ok ( Done ( ) ) | _ -> Error ` Bad_payload let index_search payload = let open Result . Monad_infix in run ' \ x1A ' payload Pb_response . index_search >>= fun ( ks , rs , cont , _d ) -> Ok ( Done { keys = ks ; results = rs ; continuation = cont } ) |
let index_search_stream payload = let open Result . Monad_infix in run ' \ x1A ' payload Pb_response . index_search >>= function | ( ks , rs , _ , Some false ) | ( ks , rs , _ , None ) -> Ok ( More { keys = ks ; results = rs ; continuation = None } ) | ( ks , rs , cont , Some true ) -> Ok ( Done { keys = ks ; results =... |
let parse_length s = let bits = Bitstring . bitstring_of_string s in let to_int = Int32 . to_int in let module Int32 = Old_int32 in let module Char = Old_char in let module String = Old_string in let open Result . Monad_infix in bitmatch bits with | { len : 32 : bigendian } -> begin match to_int len with end | { _ } ->... |
let option_string = option string |
let s = " ReWeb . Response " , [ test_case " add_cookie " ` Quick begin fun ( ) -> " " |> of_binary |> add_cookie @@ Header . SetCookie . make ~ name " 0 " |> cookies |> List . map Header . SetCookie . to_header |> check ( list ( pair string string ) ) " " @@ [ " set - cookie " , " x = 0 ; Secure ; HttpOnly ; SameSite ... |
let assert_equal ~ printer ~ msg ~ expected actual = if expected = actual then ( ) else raise ( Failure ( Printf . sprintf " % s expected [ % s ] but got [ % s ] " msg ( printer expected ) ( printer actual ) ) ) |
let assert_string ~ msg ~ expected actual = assert_equal ( fun s -> s ) msg expected actual |
let assert_int ~ msg ~ expected actual = assert_equal string_of_int msg expected actual |
let assert_bool ~ msg ~ expected actual = assert_equal string_of_bool msg expected actual |
let assert_option ~ printer ~ msg ~ expected actual = let printer = function | Some x -> " Some ( " ^ printer x ^ " ) " | None -> " None " in assert_equal printer msg expected actual |
let assert_string_option ~ msg ~ expected actual = assert_option ( fun s -> s ) msg expected actual |
let tests = [ " AvailablePhoneNumbers / Local " , ( fun ( ) -> let open Available_phone_numbers_local_j in let r = response_of_string " { " \ uri " \: " \\\/ 2010 - 04 - 01 \\/ Accounts \\/ ACde6f1e11047ebd6fe7a55f120be3a900 \\/ AvailablePhoneNumbers \\/ US \\/ Local . json ? AreaCode = 510 " , \ " \ available_phone_nu... |
let test_runner tests = let progress ( ) = output_char stderr ' . ' ; flush stderr in List . iter ( fun ( name , fn ) -> progress ( ) ; try fn ( ) with e -> let msg = Printf . sprintf " \ n \ nIn test [ % s ] :\ n % s \ n % s " name ( Printexc . to_string e ) ( Printexc . get_backtrace ( ) ) in failwith msg ) tests |
let _ = Printexc . record_backtrace true ; test_runner tests ; print_endline " \ nSUCCESS " |
module Images = struct type t = MaxWidth of int * int * t | Default of int type conf = { root : Fpath . t ; conf : Image . Transform . conf } let rec get_default_size = function | Default i -> i | MaxWidth ( _ , _ , xs ) -> get_default_size xs let rec get_sizes = function | Default i -> [ float_of_int i ] | MaxWidth ( ... |
type path = RESTConv . fmt * ( path_atom list ) |
type status = New | Standard | Deprecated |
type section_t = { sct_title : string ; sct_help : mkd ; sct_order : int ; sct_base : path_atom list ; } |
type ( ' a , ' b , ' c ) function_t = { fun_section : section_t ; fun_title : string ; fun_default_path : path ; fun_other_paths : path list ; fun_params : ' a RESTParams . t ; fun_valid_versions : comparator ; fun_status : status ; fun_help : mkd ; fun_examples : ( mkd * ' a * ' b ) list ; fun_act : ' c -> ' a -> ' b ... |
module SetString = Set . Make ( String ) |
module type VERSIONS = sig val current_version : OASISVersion . t val past_versions : OASISVersion . t list end |
module Make ( V : VERSIONS ) = let mk_paths ( ? versions = V . current_version :: V . past_versions ) ( ? fmts [ = Sexp ; JSON ] ) valid_versions section path = let versions = List . filter ( fun v -> comparator_apply v valid_versions ) versions in let tail_path = section . sct_base @ path in let acc = [ ] in let paths... |
type fmt = | Sexp | JSON |
let string_of_fmt = function | Sexp -> " sexp " | JSON -> " json " |
let mime_of_fmt = function | Sexp -> " sexp / application " | JSON -> " json / application " |
type ' a t = { to_sexp : ' a -> Sexplib . Sexp . t ; of_sexp : Sexplib . Sexp . t -> ' a ; to_json : ' a -> Yojson . Basic . json ; of_json : Yojson . Basic . json -> ' a ; } |
let string = { to_sexp = sexp_of_string ; of_sexp = string_of_sexp ; to_json = ( fun str -> ` String str ) ; of_json = ( function | ` String str -> str | e -> assert ( false ) ) ; } |
let list t = { to_sexp = sexp_of_list t . to_sexp ; of_sexp = list_of_sexp t . of_sexp ; to_json = ( fun lst -> ` List ( List . map t . to_json lst ) ) ; of_json = ( function | ` List lst -> List . map t . of_json lst | e -> assert ( false ) ) ; } |
let wrap conv_to conv_of t = { to_sexp = ( fun v -> t . to_sexp ( conv_to v ) ) ; of_sexp = ( fun s -> conv_of ( t . of_sexp s ) ) ; to_json = ( fun v -> t . to_json ( conv_to v ) ) ; of_json = ( fun s -> conv_of ( t . of_json s ) ) ; } |
let version = wrap string_of_version version_of_string string |
type ctxt = { base_url : string ; curl_socket : Curl . t ; dbug_print : string -> unit ; } |
let create ( ? dbug_print = ignore ) base_url curl_socket = { base_url = base_url ; curl_socket = curl_socket ; dbug_print = dbug_print ; } |
let mk_fun api_fun ~ ctxt params = let rec chop_slash str = if String . ends_with str " " / then chop_slash ( String . rchop str ) else str in let fmt , tail_path = api_fun . fun_default_path in let params_str = let rec get_params p = match p with | RESTParams . Unit -> Obj . magic ( fun acc ( ) -> acc ) | RESTParams .... |
let map_option f = function | None -> None | Some x -> Some ( f x ) |
module Internal = struct module Ty = struct type ' a witness = . . exception Not_equal type ( _ , _ ) eq = Eq : ( ' a , ' a ) eq module type Ty = sig type t val witness : t witness val eq : ' a witness -> ( ' a , t ) eq end type ' a id = ( module Ty with type t = ' a ) let new_id ( type a ) ( ) = let module Ty = struct... |
module Arg = struct type descr = Internal . descr = { name : string ; descr : string option ; } type ' a arg = ' a Internal . arg let eq a b = Ty . eq a . id b . id let make ? descr ~ name ~ destruct ~ construct ( ) = let id = Ty . new_id ( ) in let descr = { name ; descr } in { descr ; id ; construct ; destruct } let ... |
module Path = struct type ( ' a , ' b ) rpath = ( ' a , ' b ) Internal . rpath type ( ' a , ' b ) path = ( ' a , ' b ) Internal . path type ' prefix context = ( ' prefix , ' prefix ) path let root = Path Root let add_suffix path name = match path with | Path path -> Path ( Static ( path , name ) ) | MappedPath ( path ,... |
type ( ' prefix , ' params , ' input , ' output ) service = ( ' prefix , ' params , ' input , ' output ) Internal . iservice |
let service ? description ~ input ~ output path = { description ; path ; input ; output } |
let prefix path s = { s with path = Path . prefix path s . path } |
module Make ( Repr : Json_repr . Repr ) = struct open Json_encoding include Make ( Repr ) type json = Repr . value let rec forge_request_args : type p . ( unit , p ) path -> p -> string list = fun path args -> let rec forge_request_args : type k . ( unit , k ) rpath -> k -> string list -> string list = fun path args ac... |
module Description = struct type service_descr = { description : string option ; input : Json_schema . schema ; output : Json_schema . schema ; } let service_descr_encoding = let open Json_encoding in conv ( fun { description ; input ; output } -> ( description , input , output ) ) ( fun ( description , input , output ... |
type help = { help_valid_versions : comparator ; help_section : section_t ; help_title : string ; help_txt : mkd ; help_examples : ( mkd * ( ( string_uri * string ) list ) ) list ; help_status : status ; } |
let help_data = ref [ ] |
let register_new_service ( rewrite : server_params -> uri -> uri ) get_t base_path api_fun = let get_params = let rec get_params ' p = match p with | RESTParams . Unit -> Obj . magic unit | RESTParams . String nm -> Obj . magic ( string nm ) | RESTParams . Cross ( p1 , p2 ) -> Obj . magic ( ( get_params ' p1 ) ** ( get... |
let help_box ~ sp html_of_mkd ( ) = let help_data = List . map ( fun f -> f sp ) ! help_data in let all_help = List . sort ( fun { help_section = { sct_order = i1 } } { help_section = { sct_order = i2 } } -> i1 - i2 ) help_data in let help_one t = [ h3 [ pcdata ( s_ t . help_title ) ] ; ( let status , text = match t . ... |
let map_option f = function | None -> None | Some x -> Some ( f x ) |
module Internal = struct type ( _ , _ , _ , _ , _ , _ ) conv = | Z : ( unit , ' g , ' g , unit , ' f , ' f ) conv | S : ( ' t , ' g , ' b * ' s , ' rt , ' f , ' r ) conv -> ( ' t * ' b , ' g , ' s , ' a * ' rt , ' a -> ' f , ' r ) conv let reverse : type a b c d e f . ( a , c , unit , d , e , f ) conv -> a -> c = fun c... |
let descr x = x . Arg . descr |
module Answer = struct type ' a stream = { next : unit -> ' a option Lwt . t ; shutdown : unit -> unit ; } type ' a output = | Empty | Single of ' a | Stream of ' a stream type ' a answer = { code : int ; body : ' a output ; } let ok json = { code = 200 ; body = Single json } let return json = Lwt . return { code = 200... |
type step = | Static of string | Dynamic of Arg . descr |
type conflict = | CService | CDir | CBuilder | CCustom | CTypes of Arg . descr * Arg . descr | CType of Arg . descr * string list |
module Make ( Repr : Json_repr . Repr ) = struct open Resto . Internal include Json_encoding . Make ( Repr ) type ' key directory = | Map : ( ' key -> ' inner_key ) * ' inner_key directory -> ' key directory | Static : ' key static_directory -> ' key directory | Dynamic : string option * ( ' key -> ' key directory Lwt ... |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2016 - 11 - 15 " ] ) ; ( " Action " , [ " RestoreAddressToClassic " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " RestoreAddressToClassicResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp RestoreAddressToClassicResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed RestoreAddressToC... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RestoreDBClusterFromS3 " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query .... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RestoreDBClusterFromS3Response " ( snd xml ) ) ( Xml . member " RestoreDBClusterFromS3Result " ) in try Util . or_error ( Util . option_bind resp RestoreDBClusterFromS3Result . parse ) ( let open Error in BadRes... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RestoreDBClusterFromSnapshot " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Q... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RestoreDBClusterFromSnapshotResponse " ( snd xml ) ) ( Xml . member " RestoreDBClusterFromSnapshotResult " ) in try Util . or_error ( Util . option_bind resp RestoreDBClusterFromSnapshotResult . parse ) ( let op... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RestoreDBClusterToPointInTime " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RestoreDBClusterToPointInTimeResponse " ( snd xml ) ) ( Xml . member " RestoreDBClusterToPointInTimeResult " ) in try Util . or_error ( Util . option_bind resp RestoreDBClusterToPointInTimeResult . parse ) ( let... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RestoreDBInstanceFromDBSnapshot " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RestoreDBInstanceFromDBSnapshotResponse " ( snd xml ) ) ( Xml . member " RestoreDBInstanceFromDBSnapshotResult " ) in try Util . or_error ( Util . option_bind resp RestoreDBInstanceFromDBSnapshotResult . parse )... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RestoreDBInstanceFromS3 " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RestoreDBInstanceFromS3Response " ( snd xml ) ) ( Xml . member " RestoreDBInstanceFromS3Result " ) in try Util . or_error ( Util . option_bind resp RestoreDBInstanceFromS3Result . parse ) ( let open Error in Bad... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " RestoreDBInstanceToPointInTime " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded (... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " RestoreDBInstanceToPointInTimeResponse " ( snd xml ) ) ( Xml . member " RestoreDBInstanceToPointInTimeResult " ) in try Util . or_error ( Util . option_bind resp RestoreDBInstanceToPointInTimeResult . parse ) ( ... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2016 - 11 - 15 " ] ) ; ( " Action " , [ " RestoreManagedPrefixListVersion " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ... |
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " RestoreManagedPrefixListVersionResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp RestoreManagedPrefixListVersionResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed R... |
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None |
let repeat_service = service ~ input : Json_encoding . any_ezjson_value ~ output : Json_encoding . any_ezjson_value Path . ( root / " foo " /: Arg . int / " repeat " ) |
let add_service = service ~ input : Json_encoding . int ~ output : Json_encoding . int Path . ( root / " foo " /: Arg . int / " add " ) |
let alternate_add_service = service ~ input : Json_encoding . null ~ output : Json_encoding . float Path . ( root / " bar " /: Arg . int /: Arg . float / " add " ) |
let alternate_add_service ' = service ~ input : Json_encoding . null ~ output : Json_encoding . int Path . ( map ( fun ( ( ( ) , i ) , f ) -> ( i , int_of_float f ) ) ( fun ( i , f ) -> ( ( ( ) , i ) , float_of_int f ) ) ( root / " bar " /: Arg . int /: Arg . float / " add ' " ) ) |
let minus_service custom_root = service ~ input : Json_encoding . null ~ output : Json_encoding . float Path . ( custom_root /: Arg . int / " minus " ) |
let describe_service = Description . service Path . ( root / " describe " ) |
let dummy_service = service ~ input : Json_encoding . null ~ output : Json_encoding . null Path . ( root / " a " / " path " / " long " / " enough " / " for " / " < hov " > / " to " / " trigger " /: Arg . float /: Arg . float /: Arg . float /: Arg . float /: Arg . float /: Arg . float /: Arg . float ) |
let prefix_dir1 = Path . ( root / " tartine " /: Arg . float / " chaussure " ) |
let prefix_dir2 = Path . ( root / " epice " /: Arg . int ) |
let real_minus_service1 = minus_service prefix_dir1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.