Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_load_balancers as api_get_v2_load_balancers
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner

Expand All @@ -28,13 +29,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_load_balancer_id(ref: str) -> Union[None, int]:
return api_get_v2_load_balancers.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"load_balancer_id",
int,
required=True,
option_name=None,
description="""The ID of the load balancer to cancel.""",
metavar="load_balancer",
description="""The ID or name of the load balancer to cancel.""",
lookup=lookup_load_balancer_id,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_load_balancers as api_get_v2_load_balancers
from binarylane.console.parser import ListAttribute, Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner

Expand All @@ -34,13 +35,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_load_balancer_id(ref: str) -> Union[None, int]:
return api_get_v2_load_balancers.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"load_balancer_id",
int,
required=True,
option_name=None,
description="""The ID of the load balancer for which forwarding rules should be removed.""",
metavar="load_balancer",
description="""The ID or name of the load balancer for which forwarding rules should be removed.""",
lookup=lookup_load_balancer_id,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_load_balancers as api_get_v2_load_balancers
import binarylane.console.commands.api.get_v2_servers as api_get_v2_servers
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner
Expand All @@ -33,13 +34,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_load_balancer_id(ref: str) -> Union[None, int]:
return api_get_v2_load_balancers.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"load_balancer_id",
int,
required=True,
option_name=None,
description="""The ID of the load balancer for which servers should be removed.""",
metavar="load_balancer",
description="""The ID or name of the load balancer for which servers should be removed.""",
lookup=lookup_load_balancer_id,
)
)

Expand Down
8 changes: 7 additions & 1 deletion src/binarylane/console/commands/api/delete_v2_vpcs_vpc_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_vpcs as api_get_v2_vpcs
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner

Expand All @@ -28,13 +29,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_vpc_id(ref: str) -> Union[None, int]:
return api_get_v2_vpcs.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"vpc_id",
int,
required=True,
option_name=None,
description="""The target vpc id.""",
metavar="vpc",
description="""The target vpc id or name.""",
lookup=lookup_vpc_id,
)
)

Expand Down
13 changes: 13 additions & 0 deletions src/binarylane/console/commands/api/get_v2_load_balancers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union

from binarylane.api.load_balancers.get_v2_load_balancers import sync_detailed
from binarylane.console.util import create_client
from binarylane.models.links import Links
from binarylane.models.load_balancers_response import LoadBalancersResponse

Expand Down Expand Up @@ -55,6 +56,18 @@ def fields(self) -> Dict[str, str]:
"region": """The region the load balancer is located in. If this value is null the load balancer is an 'AnyCast' load balancer.""",
}

def lookup(self, ref: str) -> Optional[int]:
status_code, received = self.request(create_client(self._context), CommandRequest())
if status_code != 200:
super().response(status_code, received)

assert isinstance(received, LoadBalancersResponse)
for item in received.load_balancers:
if item.name == ref:
return item.id
else:
return None

@property
def reference_url(self) -> str:
return "https://api.binarylane.com.au/reference/#tag/LoadBalancers/paths/~1v2~1load_balancers/get"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_load_balancers as api_get_v2_load_balancers
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner

Expand All @@ -29,13 +30,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_load_balancer_id(ref: str) -> Union[None, int]:
return api_get_v2_load_balancers.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"load_balancer_id",
int,
required=True,
option_name=None,
description="""The ID of the load balancer to fetch.""",
metavar="load_balancer",
description="""The ID or name of the load balancer to fetch.""",
lookup=lookup_load_balancer_id,
)
)

Expand Down
13 changes: 13 additions & 0 deletions src/binarylane/console/commands/api/get_v2_vpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union

from binarylane.api.vpcs.get_v2_vpcs import sync_detailed
from binarylane.console.util import create_client
from binarylane.models.links import Links
from binarylane.models.vpcs_response import VpcsResponse

Expand Down Expand Up @@ -42,6 +43,18 @@ def fields(self) -> Dict[str, str]:
"route_entries": """The route entries that control how network traffic is directed through the VPC environment.""",
}

def lookup(self, ref: str) -> Optional[int]:
status_code, received = self.request(create_client(self._context), CommandRequest())
if status_code != 200:
super().response(status_code, received)

assert isinstance(received, VpcsResponse)
for item in received.vpcs:
if item.name == ref:
return item.id
else:
return None

@property
def reference_url(self) -> str:
return "https://api.binarylane.com.au/reference/#tag/Vpcs/paths/~1v2~1vpcs/get"
Expand Down
8 changes: 7 additions & 1 deletion src/binarylane/console/commands/api/get_v2_vpcs_vpc_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_vpcs as api_get_v2_vpcs
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner

Expand All @@ -29,13 +30,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_vpc_id(ref: str) -> Union[None, int]:
return api_get_v2_vpcs.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"vpc_id",
int,
required=True,
option_name=None,
description="""The target vpc id.""",
metavar="vpc",
description="""The target vpc id or name.""",
lookup=lookup_vpc_id,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_vpcs as api_get_v2_vpcs
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.list import ListRunner

Expand Down Expand Up @@ -66,13 +67,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_vpc_id(ref: str) -> Union[None, int]:
return api_get_v2_vpcs.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"vpc_id",
int,
required=True,
option_name=None,
description="""The target vpc id.""",
metavar="vpc",
description="""The target vpc id or name.""",
lookup=lookup_vpc_id,
)
)

Expand Down
8 changes: 7 additions & 1 deletion src/binarylane/console/commands/api/patch_v2_vpcs_vpc_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_vpcs as api_get_v2_vpcs
from binarylane.console.parser import ListAttribute, Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner

Expand All @@ -35,13 +36,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_vpc_id(ref: str) -> Union[None, int]:
return api_get_v2_vpcs.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"vpc_id",
int,
required=True,
option_name=None,
description="""The target vpc id.""",
metavar="vpc",
description="""The target vpc id or name.""",
lookup=lookup_vpc_id,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_load_balancers as api_get_v2_load_balancers
from binarylane.console.parser import ListAttribute, Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner

Expand All @@ -34,13 +35,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_load_balancer_id(ref: str) -> Union[None, int]:
return api_get_v2_load_balancers.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"load_balancer_id",
int,
required=True,
option_name=None,
description="""The ID of the load balancer to which forwarding rules should be added.""",
metavar="load_balancer",
description="""The ID or name of the load balancer to which forwarding rules should be added.""",
lookup=lookup_load_balancer_id,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_load_balancers as api_get_v2_load_balancers
import binarylane.console.commands.api.get_v2_servers as api_get_v2_servers
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.command import CommandRunner
Expand All @@ -33,13 +34,18 @@ def reference_url(self) -> str:
def create_mapping(self) -> Mapping:
mapping = Mapping(CommandRequest)

def lookup_load_balancer_id(ref: str) -> Union[None, int]:
return api_get_v2_load_balancers.Command(self._context).lookup(ref)

mapping.add(
PrimitiveAttribute(
"load_balancer_id",
int,
required=True,
option_name=None,
description="""The ID of the load balancer to which servers should be added.""",
metavar="load_balancer",
description="""The ID or name of the load balancer to which servers should be added.""",
lookup=lookup_load_balancer_id,
)
)

Expand Down
8 changes: 7 additions & 1 deletion src/binarylane/console/commands/api/post_v2_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
if TYPE_CHECKING:
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_vpcs as api_get_v2_vpcs
from binarylane.console.parser import ListAttribute, Mapping, ObjectAttribute, PrimitiveAttribute
from binarylane.console.runners.actionlink import ActionLinkRunner

Expand Down Expand Up @@ -95,13 +96,18 @@ def create_mapping(self) -> Mapping:
)
)

def lookup_vpc_id(ref: str) -> Union[None, int]:
return api_get_v2_vpcs.Command(self._context).lookup(ref)

json_body.add(
PrimitiveAttribute(
"vpc_id",
Union[Unset, None, int],
required=False,
option_name="vpc-id",
option_name=("vpc", "vpc-id"),
metavar="vpc",
description="""Leave null to use default (public) network for the selected region.""",
lookup=lookup_vpc_id,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from binarylane.client import Client

import binarylane.console.commands.api.get_v2_servers as api_get_v2_servers
import binarylane.console.commands.api.get_v2_vpcs as api_get_v2_vpcs
from binarylane.console.parser import Mapping, PrimitiveAttribute
from binarylane.console.runners.action import ActionRunner

Expand Down Expand Up @@ -62,13 +63,18 @@ def lookup_server_id(ref: str) -> Union[None, int]:
)
)

def lookup_vpc_id(ref: str) -> Union[None, int]:
return api_get_v2_vpcs.Command(self._context).lookup(ref)

json_body.add(
PrimitiveAttribute(
"vpc_id",
Union[Unset, None, int],
required=False,
option_name="vpc-id",
option_name=("vpc", "vpc-id"),
metavar="vpc",
description="""If this is null the server will be moved into the default public network for the server's region.""",
lookup=lookup_vpc_id,
)
)

Expand Down
Loading
Loading