summaryrefslogtreecommitdiff
path: root/src/vyconf_client.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/vyconf_client.ml')
-rw-r--r--src/vyconf_client.ml27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/vyconf_client.ml b/src/vyconf_client.ml
index c4811c5..05b5548 100644
--- a/src/vyconf_client.ml
+++ b/src/vyconf_client.ml
@@ -53,10 +53,10 @@ let prompt client =
let%lwt resp = do_request client req in
Lwt.return resp
-let setup_session ?(on_behalf_of=None) client client_app =
+let setup_session ?(on_behalf_of=None) client client_app pid =
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 req = Setup_session {client_application=(Some client_app); on_behalf_of=id; client_pid=pid} in
let%lwt resp = do_request client req in
match resp.status with
| Success ->
@@ -65,6 +65,13 @@ let setup_session ?(on_behalf_of=None) client client_app =
| None -> Error "setup_session did not return a session token!") |> Lwt.return
| _ -> Error (Option.value resp.error ~default:"Unknown error") |> Lwt.return
+let session_of_pid client pid =
+ let req = Session_of_pid {client_pid=pid} in
+ let%lwt resp = do_request client req in
+ (match resp.output with
+ | Some token -> Ok {client with session=(Some token)}
+ | None -> Error "no such session") |> Lwt.return
+
let teardown_session ?(on_behalf_of=None) client =
let id = on_behalf_of |> (function None -> None | Some x -> (Some (Int32.of_int x))) in
let req = Teardown {on_behalf_of=id} in
@@ -134,6 +141,22 @@ let delete client path =
| Fail -> Error (Option.value resp.error ~default:"") |> Lwt.return
| _ -> Error (Option.value resp.error ~default:"") |> Lwt.return
+let session_changed client =
+ let req = Session_changed {dummy=None;} in
+ let%lwt resp = do_request client req in
+ match resp.status with
+ | Success -> Lwt.return (Ok "")
+ | Fail -> Error (Option.value resp.error ~default:"") |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"") |> Lwt.return
+
+let discard client =
+ let req = Discard {dummy=None;} in
+ let%lwt resp = do_request client req in
+ match resp.status with
+ | Success -> Lwt.return (Ok "")
+ | Fail -> Error (Option.value resp.error ~default:"") |> Lwt.return
+ | _ -> Error (Option.value resp.error ~default:"") |> Lwt.return
+
let commit client =
let req =
Commit {confirm=None; confirm_timeout=None; comment=None; dry_run=None}