From c3c44d61e43cf7139c4e88172c0cf670be100007 Mon Sep 17 00:00:00 2001 From: Paulo Ferreira Date: Sat, 23 Oct 2021 05:34:39 -0300 Subject: [PATCH] Add method rename client (#133) * Update Client.php Add method rename client * Update README.md --- README.md | 1 + src/Client.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index e1e46a9..504e48c 100755 --- a/README.md +++ b/README.md @@ -170,6 +170,7 @@ more details on the functions/methods and their respective parameters. - disable_ap() - edit_apgroup() (supported with controller versions 6.0.X and higher) - edit_client_fixedip() +- edit_client_name() - edit_firewallgroup() - edit_usergroup() - extend_guest_validity() diff --git a/src/Client.php b/src/Client.php index 32f3df0..378c548 100755 --- a/src/Client.php +++ b/src/Client.php @@ -1101,6 +1101,28 @@ class Client return $this->fetch_results('/api/s/' . $this->site . '/rest/user/' . trim($client_id), $payload); } + /** + * Update client name (using REST) + * + * @param string $client_id _id value for the client + * @param bool $name of the client + * @return array|false returns an array containing a single object with attributes of the updated client on success + */ + public function edit_client_name($client_id, $name) + { + if (empty($name)) { + return false; + } + + $this->curl_method = 'PUT'; + $payload = [ + '_id' => $client_id, + 'name' => $name, + ]; + + return $this->fetch_results('/api/s/' . $this->site . '/rest/user/' . trim($client_id), $payload); + } + /** * Fetch user groups *