How to use the cloudbridge.cloud.interfaces.resources.PageableObjectMixin function in cloudbridge

To help you get started, we’ve selected a few cloudbridge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
# print all VM firewalls
            for fw in provider.security.vm_firewalls:
                print(fw.id, fw.name)

            # find firewall by name
            fw = provider.security.vm_firewalls.find(name='my_vm_fw')[0]
            print(fw.id, fw.name)

        :rtype: :class:`.VMFirewallService`
        :return: a VMFirewallService object
        """
        pass


class KeyPairService(PageableObjectMixin, CloudService):

    """
    Base interface for key pairs.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, key_pair_id):
        """
        Return a KeyPair given its ID or ``None`` if not found.

        On some providers, such as AWS and OpenStack, the KeyPair ID is
        the same as its name.

        Example:
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
:return:  A Router object
        """
        pass

    @abstractmethod
    def delete(self, router):
        """
        Delete an existing Router.

        :type router: :class:`.Router` object or ``str``
        :param router: Router object or ID of the router to delete.
        """
        pass


class BucketService(PageableObjectMixin, CloudService):

    """
    The Bucket Service interface provides access to the underlying
    object storage capabilities of this provider. This service is optional and
    the :func:`CloudProvider.has_service()` method should be used to verify its
    availability before using the service.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, bucket_id):
        """
        Returns a bucket given its ID. Returns ``None`` if the bucket
        does not exist. On some providers, such as AWS and OpenStack,
        the bucket id is the same as its name.
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
# Print all subnets
            for s in provider.networking.subnets:
                print(s.id, s.name, s.label)

            # Get subnet by ID
            s = provider.networking.subnets.get('subnet-id')
            print(s.id, s.name, s.label)

        :rtype: :class:`.SubnetService`
        :return: a SubnetService object
        """
        pass


class SubnetService(PageableObjectMixin, CloudService):

    """
    Base interface for a Subnet Service.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, subnet_id):
        """
        Returns a Subnet given its ID or ``None`` if not found.

        :type subnet_id: :class:`.Network` object or ``str``
        :param subnet_id: The ID of the subnet to retrieve.

        :rtype: ``object`` of :class:`.Subnet`
        :return: a Subnet object
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
# print all buckets
            for bucket in provider.storage.buckets:
                print(bucket.id, bucket.name)

            # find bucket by name
            bucket = provider.storage.buckets.find(name='my_bucket')[0]
            print(bucket.id, bucket.name)

        :rtype: :class:`.BucketService`
        :return: a BucketService object
        """
        pass


class ImageService(PageableObjectMixin, CloudService):

    """
    Base interface for an Image Service
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, image_id):
        """
        Returns an Image given its id. Returns None if the Image does not
        exist.

        :rtype: ``object`` of :class:`.Image`
        :return:  an Image instance
        """
        pass
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
    @abstractmethod
    def delete(self, firewall, rule_id):
        """
        Delete an existing VMFirewall rule.

        :type firewall: ``VMFirewall``
        :param firewall: The firewall to which the rule is attached

        :type rule_id: str
        :param rule_id: The VM firewall rule to be deleted.
        """
        pass


class VMTypeService(PageableObjectMixin, CloudService):
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, vm_type_id):
        """
        Returns an VMType given its ID. Returns ``None`` if the
        VMType does not exist.

        Example:

        .. code-block:: python

            vm_type = provider.compute.vm_types.get('my_vm_type_id')
            print(vm_type.id, vm_type.name)

        :rtype: :class:`.VMType`
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
"""
        pass

    @abstractproperty
    def _vm_firewall_rules(self):
        """
        Provides access to firewall (security group) rules for this provider.
        This service is not iterable.

        :rtype: :class:`.VMFirewallRuleService`
        :return: a VMFirewallRuleService object
        """
        pass


class KeyPairService(PageableObjectMixin, CloudService):

    """
    Base interface for key pairs.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, key_pair_id):
        """
        Return a KeyPair given its ID or ``None`` if not found.

        On some providers, such as AWS and OpenStack, the KeyPair ID is
        the same as its name.

        Example:
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
:return:  A Router object
        """
        pass

    @abstractmethod
    def delete(self, router):
        """
        Delete an existing Router.

        :type router: :class:`.Router` object or ``str``
        :param router: Router object or ID of the router to delete.
        """
        pass


class BucketService(PageableObjectMixin, CloudService):

    """
    The Bucket Service interface provides access to the underlying
    object storage capabilities of this provider. This service is optional and
    the :func:`CloudProvider.has_service()` method should be used to verify its
    availability before using the service.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, bucket_id):
        """
        Returns a bucket given its ID. Returns ``None`` if the bucket
        does not exist. On some providers, such as AWS and OpenStack,
        the bucket id is the same as its name.
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / resources.py View on Github external
"""
    Standard states for a gateway.

    :cvar UNKNOWN: Gateway state unknown.
    :cvar CONFIGURING: Gateway is being configured
    :cvar AVAILABLE: Gateway is ready
    :cvar ERROR: Gateway is ready

    """
    UNKNOWN = "unknown"
    CONFIGURING = "configuring"
    AVAILABLE = "available"
    ERROR = "error"


class GatewayContainer(PageableObjectMixin):
    """
    Manage internet gateway resources.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get_or_create_inet_gateway(self, label=None):
        """
        Creates new or returns an existing internet gateway for a network.

        The returned gateway object can subsequently be attached to a router to
        provide internet routing to a network.

        :type  label: ``str``
        :param label: The gateway label.
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
# Print all subnets
            for s in provider.networking.subnets:
                print(s.id, s.name, s.label)

            # Get subnet by ID
            s = provider.networking.subnets.get('subnet-id')
            print(s.id, s.name, s.label)

        :rtype: :class:`.SubnetService`
        :return: a SubnetService object
        """
        pass


class SubnetService(PageableObjectMixin, CloudService):

    """
    Base interface for a Subnet Service.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def get(self, subnet_id):
        """
        Returns a Subnet given its ID or ``None`` if not found.

        :type subnet_id: :class:`.Network` object or ``str``
        :param subnet_id: The ID of the subnet to retrieve.

        :rtype: ``object`` of :class:`.Subnet`
        return: a Subnet object
github CloudVE / cloudbridge / cloudbridge / cloud / interfaces / services.py View on Github external
Example:

        .. code-block:: python

            for region in provider.compute.regions:
                print("Region: ", region.name)
                for zone in region.zones:
                   print("\\tZone: ", zone.name)

        :rtype: :class:`.RegionService`
        :return: a RegionService object
        """
        pass


class InstanceService(PageableObjectMixin, CloudService):
    """
    Provides access to instances in a provider, including creating,
    listing and deleting instances.
    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def __iter__(self):
        """
        Iterate through the  list of instances.

        Example:
        ```
        for instance in provider.compute.instances:
            print(instance.name)
        ```