Source code for linode_api4.groups.nodebalancer

from linode_api4.errors import UnexpectedResponseError
from linode_api4.groups import Group
from linode_api4.objects import Base, NodeBalancer, NodeBalancerType


[docs] class NodeBalancerGroup(Group):
[docs] def __call__(self, *filters): """ Retrieves all of the NodeBalancers the acting user has access to. This is intended to be called off of the :any:`LinodeClient` class, like this:: nodebalancers = client.nodebalancers() API Documentation: https://techdocs.akamai.com/linode-api/reference/get-node-balancers :param filters: Any number of filters to apply to this query. See :doc:`Filtering Collections</linode_api4/objects/filtering>` for more details on filtering. :returns: A list of NodeBalancers the acting user can access. :rtype: PaginatedList of NodeBalancers """ return self.client._get_and_filter(NodeBalancer, *filters)
[docs] def create(self, region, **kwargs): """ Creates a new NodeBalancer in the given Region. API Documentation: https://techdocs.akamai.com/linode-api/reference/post-node-balancer :param region: The Region in which to create the NodeBalancer. :type region: Region or str :param ipv4: A reserved IPv4 address to assign to this NodeBalancer. NOTE: Reserved IP feature may not currently be available to all users. :type ipv4: str :returns: The new NodeBalancer :rtype: NodeBalancer """ ipv4 = kwargs.pop("ipv4", None) params = { "region": region.id if isinstance(region, Base) else region, } if ipv4 is not None: params["ipv4"] = ipv4 params.update(kwargs) result = self.client.post("/nodebalancers", data=params) if not "id" in result: raise UnexpectedResponseError( "Unexpected response when creating NodeBalancer!", json=result ) n = NodeBalancer(self.client, result["id"], result) return n
[docs] def types(self, *filters): """ Returns a :any:`PaginatedList` of :any:`NodeBalancerType` objects that represents a valid NodeBalancer type. API Documentation: https://techdocs.akamai.com/linode-api/reference/get-node-balancer-types :param filters: Any number of filters to apply to this query. See :doc:`Filtering Collections</linode_api4/objects/filtering>` for more details on filtering. :returns: A Paginated List of NodeBalancer types that match the query. :rtype: PaginatedList of NodeBalancerType """ return self.client._get_and_filter( NodeBalancerType, *filters, endpoint="/nodebalancers/types" )