Skip to content

Commit

Permalink
fix: check bots by network
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdang committed Jan 14, 2025
1 parent d99cc72 commit 3ce8c4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,8 @@ def new_bot(
):
"""Create a new bot in a CLUSTER with the given configuration"""

if name in cluster.bots:
raise click.UsageError(f"Cannot use name '{name}' to create bot")
if name in cluster.bots_by_network(network=network):
raise click.UsageError(f"Bot name {name} already exists in network {network}.")

vargroup = [group for group in vargroups]

Expand Down
5 changes: 5 additions & 0 deletions silverback/cluster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ def bots(self) -> dict[str, Bot]:
handle_error_with_response(response)
return {bot.name: bot for bot in map(Bot.model_validate, response.json())}

def bots_by_network(self, network: str) -> dict[str, Bot]:
response = self.get(f"/bots/network/{network}")
handle_error_with_response(response)
return {bot.name: bot for bot in map(Bot.model_validate, response.json())}

def new_bot(
self,
name: str,
Expand Down

0 comments on commit 3ce8c4e

Please sign in to comment.