Skip to content

Commit

Permalink
feat(static-route): add support for updating static-route
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitrgadiya committed Feb 26, 2024
1 parent 85010ed commit c2a5305
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion riocli/static_route/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 18 additions & 0 deletions riocli/v2client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2a5305

Please sign in to comment.