summaryrefslogtreecommitdiff
path: root/src/vyconf_client.ml
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-10-23 18:50:46 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-10-27 20:50:41 -0500
commit5d7927e392e70436aaca1f8261e5d4ab8e4ec8f8 (patch)
treed824589851f788ab4864c31b44ec6cbab2f5cefe /src/vyconf_client.ml
parentdd9271b4304c6b1a5a2576821d1b2b8fd3aa6bf5 (diff)
downloadvyconf-5d7927e392e70436aaca1f8261e5d4ab8e4ec8f8.tar.gz
vyconf-5d7927e392e70436aaca1f8261e5d4ab8e4ec8f8.zip
T6718: update build system, drop batteries, and adjust for lib changes
Update as needed for use with contemporary vyos1x-config: . update build system to use dune . drop use of batteries . update for protoc breaking changes in versions >= 3.0 . remove files now in vyos1x-config (config_tree et. al.; parsing)
Diffstat (limited to 'src/vyconf_client.ml')
-rw-r--r--src/vyconf_client.ml18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/vyconf_client.ml b/src/vyconf_client.ml
index db7d9c1..63ff121 100644
--- a/src/vyconf_client.ml
+++ b/src/vyconf_client.ml
@@ -22,8 +22,8 @@ let create ?(token=None) sockfile out_format conf_format =
let open Lwt_unix in
let sock = socket PF_UNIX SOCK_STREAM 0 in
let%lwt () = connect sock (ADDR_UNIX sockfile) in
- let ic = Lwt_io.of_fd Lwt_io.Input sock in
- let oc = Lwt_io.of_fd Lwt_io.Output sock in
+ let ic = Lwt_io.of_fd ~mode:Lwt_io.Input sock in
+ let oc = Lwt_io.of_fd ~mode:Lwt_io.Output sock in
Lwt.return {
sock=sock; ic=ic; oc=oc;
enc=(Pbrt.Encoder.create ()); closed=false;
@@ -55,7 +55,7 @@ let get_status client =
Lwt.return resp
let setup_session ?(on_behalf_of=None) client client_app =
- if BatOption.is_some client.session then Lwt.return (Error "Client is already associated with a session") else
+ if Option.is_some client.session then Lwt.return (Error "Client is already associated with a session") else
let id = on_behalf_of |> (function None -> None | Some x -> (Some (Int32.of_int x))) in
let req = Setup_session {client_application=(Some client_app); on_behalf_of=id} in
let%lwt resp = do_request client req in
@@ -64,7 +64,7 @@ let setup_session ?(on_behalf_of=None) client client_app =
(match resp.output with
| Some token -> Ok {client with session=(Some token)}
| None -> Error "setup_session did not return a session token!") |> Lwt.return
- | _ -> Error (BatOption.default "Unknown error" resp.error) |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"Unknown error") |> Lwt.return
let exists client path =
let req = Exists {path=path} in
@@ -72,33 +72,33 @@ let exists client path =
match resp.status with
| Success -> Lwt.return (Ok "")
| Fail -> Lwt.return (Error "")
- | _ -> Error (BatOption.default "" resp.error) |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"") |> Lwt.return
let get_value client path =
let req = Get_value {path=path; output_format=(Some client.out_format)} in
let%lwt resp = do_request client req in
match resp.status with
| Success -> unwrap resp.output |> Lwt.return
- | _ -> Error (BatOption.default ""resp.error) |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"") |> Lwt.return
let get_values client path =
let req = Get_values {path=path; output_format=(Some client.out_format)} in
let%lwt resp = do_request client req in
match resp.status with
| Success -> unwrap resp.output |> Lwt.return
- | _ -> Error (BatOption.default "" resp.error) |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"") |> Lwt.return
let list_children client path =
let req = List_children {path=path; output_format=(Some client.out_format)} in
let%lwt resp = do_request client req in
match resp.status with
| Success -> unwrap resp.output |> Lwt.return
- | _ -> Error (BatOption.default "" resp.error) |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"") |> Lwt.return
let show_config client path =
let req = Show_config {path=path; format=(Some client.conf_format)} in
let%lwt resp = do_request client req in
match resp.status with
| Success -> unwrap resp.output |> Lwt.return
- | _ -> Error (BatOption.default "" resp.error) |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"") |> Lwt.return