diff --git a/riocli/static_route/model.py b/riocli/static_route/model.py index 9fe3b4b0..53d9e225 100644 --- a/riocli/static_route/model.py +++ b/riocli/static_route/model.py @@ -46,7 +46,14 @@ def create_object(self, client: Client, **kwargs) -> typing.Any: return unmunchify(r) def update_object(self, client: Client, obj: typing.Any) -> None: - pass + client = new_v2_client() + + self.pop("rc", None) + + static_route = unmunchify(self) + r = client.update_static_route(obj.metadata.name, static_route) + + return unmunchify(r) def delete_object(self, client: Client, obj: typing.Any): client = new_v2_client() diff --git a/riocli/v2client/client.py b/riocli/v2client/client.py index 6fbf8b6f..b5687d2b 100644 --- a/riocli/v2client/client.py +++ b/riocli/v2client/client.py @@ -391,6 +391,24 @@ def create_static_route(self, metadata: dict) -> Munch: return munchify(data) + def update_static_route(self, name: str, sr: dict) -> Munch: + """ + Update the new static route + """ + url = "{}/v2/staticroutes/{}/".format(self._host, name) + headers = self._config.get_auth_header() + response = RestClient(url).method(HttpMethod.PUT).headers( + headers).execute(payload=sr) + + handle_server_errors(response) + + data = json.loads(response.text) + if not response.ok: + err_msg = data.get('error') + raise Exception("static routes: {}".format(err_msg)) + + return munchify(data) + def delete_static_route(self, name: str) -> Munch: """ Delete a static route by its name