def delete_lb(self, lb):
        """Delete load balancer

        :param lb: Load balancer name or ID
        :type lb: str
        :return: Delete status
        :rtype: dict
        """
        # Check if load balancer exists
        lb_info = self.get_lb(lb)
        if "errors" in lb_info:
            return lb_info

        try:
            # Connect to api endpoint for load_balancers
            path = ("/v1/load_balancers/{}?version={}&generation={}".format(
                lb_info["id"], self.cfg["version"], self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting load balancer {}. {}".format(lb, error))
            raise
示例#2
0
    def delete_image(self, image):
        """Delete image

        :param image: Image name or ID
        :type image: str
        :return: Delete status
        :rtype: dict
        """
        try:
            # Check if image exists
            image_info = self.get_image_by_name(image)
            if "errors" in image_info:
                return image_info

            # Connect to api endpoint for images
            path = ("/v1/images/{}?version={}&generation={}".format(
                image_info["id"], self.cfg["version"], self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 202:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting image with name {}. {}".format(image, error))
            raise
示例#3
0
    def delete_network_acl(self, acl):
        """Delete network ACL

        :param acl: Network ACL name or ID
        :type acl: str
        :return: Delete status
        :rtype: dict
        """
        try:
            # Check if network ACL exists
            acl_info = self.get_network_acl(acl)
            if "errors" in acl_info:
                return acl_info

            # Connect to api endpoint for network_acls
            path = ("/v1/network_acls/{}?version={}&generation={}".format(
                acl_info["id"], self.cfg["version"], self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting network ACL with {}. {}".format(acl, error))
            raise
示例#4
0
    def delete_group(self, group):
        """Delete resource group

        :param group: Resource group name or ID
        :type group:
        :return: Delete status
        :rtype: resource_deleted()
        """
        try:
            # Check if group exists
            group_info = self.get_resource_group(group)
            if "errors" in group_info:
                return group_info

            # Connect to api endpoint resource_groups
            path = ("/v2/resource_groups/{}".format(group_info["id"]))

            data = qw("rg", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting resource group {}. {}".format(group, error))
            raise
示例#5
0
    def detach_public_gateway(self, subnet):
        """Detach public gateway from a subnet

        :param subnet: Subnet name or ID
        :type subnet: str
        :return: Detach status
        :rtype: resource_deleted()
        """
        # Retrieve subnet and public gateway information to get the ID
        # (mostly useful if a name is provided)
        subnet_info = self.get_subnet(subnet)
        if "errors" in subnet_info:
            return subnet_info

        try:
            # Connect to api endpoint for subnets
            path = ("/v1/subnets/{}/public_gateway?version={}"
                    "&generation={}".format(subnet_info["id"],
                                            self.cfg["version"],
                                            self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error detaching subnet's public gateway for"
                  "subnet {}. {}".format(subnet, error))
            raise
示例#6
0
    def delete_volume(self, instance, volume):
        """Delete volume from cloud instance

        :param instance: Instance name or ID
        :type instance: str
        :param volume: Volume name or ID
        :type volume: str
        :return: Deletion status
        :rtype: dict
        """
        try:
            ci_info = self.instance.get_instance(instance)
            if "errors" in ci_info:
                return ci_info

            # Check if volume exists and retrieve information
            vol_info = self.get_volume(ci_info["name"], volume)
            if "errors" in vol_info:
                return vol_info

            path = ("/pcloud/v1/cloud-instances/{}/volumes/{}".format(
                ci_info["name"], vol_info["volumeID"]))

            data = qw("power", "DELETE", path, headers())

            # Return data
            if data["response"].status != 200:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting volume {} from cloud instance {}. {}".format(
                volume, instance, error))
示例#7
0
    def delete_bucket(self, bucket):
        """Delete bucket

        :param bucket: Bucket name
        :type bucklet: str
        :return: Deletion status
        :rtype: dict
        """
        try:
            # Pagination
            p = self.client.get_paginator('list_objects')

            # Delete objects (1000 objects max at a time)
            for page in p.paginate(Bucket=bucket):
                keys = [{
                    'Key': obj['Key']
                } for obj in page.get('Contents', [])]
                if keys:
                    self.client.delete_objects(Bucket=bucket,
                                               Delete={'Objects': keys})

            result = self.client.delete_bucket(Bucket=bucket)
            if result["ResponseMetadata"]["HTTPStatusCode"] != 204:
                return result

            return resource_deleted()

        except Exception as error:
            return resource_error("unable_to_delete", error)
示例#8
0
    def delete_instance(self, instance):
        """Delete cloud instance

        :param instance: Cloud instance ID
        :type instance: str
        :return: Deletion status
        :rtype: dict
        """
        try:
            # Check if cloud instance exists and retrieve information
            ci_info = self.get_instance(instance)
            if "errors" in ci_info:
                return ci_info

            # Connect to api endpoint for sshkeys
            path = ("/pcloud/v1/cloud-instances/{}".format(ci_info["name"]))

            data = qw("power", "DELETE", path, headers())

            # Return data
            if data["response"].status != 200:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting cloud instance {}. {}".format(
                instance, error))
示例#9
0
    def delete_security_group(self, security_group):
        """Delete security group

        :param security_group: Security group name or ID
        :type security_group: str
        :return: Delete status
        :rtype: dict
        """
        try:
            # Check if security group exists
            sg_info = self.get_security_group_by_name(security_group)
            if "errors" in sg_info:
                return sg_info

            # Connect to api endpoint for security_groups
            path = ("/v1/security_groups/{}?version={}&generation={}".format(
                sg_info["id"], self.cfg["version"], self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting security group {}. {}".format(
                security_group, error))
            raise
示例#10
0
    def delete_key(self, tenant, key):
        """Delete key

        :param tenant: Tenant ID (Account ID)
        :type tenant: str
        :param key: Key name
        :type key: str
        :return: Deletion status
        :rtype: dict
        """
        try:
            # Check if key exists
            key_info = self.get_key(tenant, key)
            if "errors" in key_info:
                return key_info

            # Connect to api endpoint for sshkeys
            path = ("/pcloud/v1/tenants/{}/sshkeys/{}".format(
                tenant, key_info["name"]))

            data = qw("power", "DELETE", path, headers())

            # Return data
            if data["response"].status != 200:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting key {}. {}".format(key, error))
示例#11
0
    def delete_ipsec_policy(self, policy):
        """Delete IPsec policy

        :param policy: IPsec policy name or ID
        :type policy: str
        :return: Delete status
        :rtype: dict
        """
        # Check if IPsec policy exists
        policy_info = self.get_ipsec_policy(policy)
        if "errors" in policy_info:
            return policy_info

        try:
            # Connect to api endpoint for ipsec_policies
            path = ("/v1/ipsec_policies/{}?version={}&generation={}".format(
                policy_info["id"], self.cfg["version"],
                self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting IPsec policy {}. {}".format(policy, error))
            raise
示例#12
0
    def delete_policy(self, policy):
        """Delete policy

        :param policy: Policy ID
        :type policy: str
        :return: Deletion status
        :rtype: dict
        """
        # Check if policy exists and get information
        policy_info = self.get_policy(policy)
        if "errors" in policy_info:
            return policy_info

        try:
            # Connect to api endpoint for policies
            path = ("/v1/policies/{}".format(policy_info["id"]))

            data = qw("auth", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting policy {}. {}".format(policy, error))
示例#13
0
    def delete_instance_interface(self, instance, interface):
        """Delete interface from instance

        :param instance: Instance name or ID
        :type instance: str
        :param interface: Interface name or ID
        :type interface: str
        :return: Delete status
        :rtype: dict
        """
        try:
            instance_info = self.get_instance(instance)
            if "errors" in instance_info:
                return instance_info

            interface_info = self.get_instance_interface(interface)
            if "errors" in interface_info:
                return interface_info

            path = ("/v1/instances/{}/network_interfaces/{}?version={}"
                    "&generation={}".format(instance_info["id"],
                                            interface_info["id"],
                                            self.cfg["version"],
                                            self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            if data["response"].status != 204:
                return data["data"]

            return resource_deleted()

        except Exception as error:
            print("Error deleting instance {}. {}".format(instance, error))
            raise
示例#14
0
    def delete_key(self, key):
        """Delete key

        :param key: Key name or ID
        :type key: str
        :return: Delete status
        :rtype: dict
        """
        try:
            # Check if key exists
            key_info = self.get_key(key)
            if "errors" in key_info:
                return key_info

            # Connect to api endpoint for keys
            path = ("/v1/keys/{}?version={}&generation={}".format(
                key_info["id"], self.cfg["version"], self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting key {}. {}".format(key, error))
            raise
示例#15
0
    def detach_volume(self, instance, attachment):
        """Detach volume from an instance

        :param instance: Instance name or ID
        :type instance: str
        :param attachment: Volume attachement name or ID
        :type attachment: str
        """
        try:
            instance_info = self.get_instance(instance)
            if "errors" in instance_info:
                return instance_info

            attachment_info = self.get_instance_volume_attachment(
                instance_info["id"], attachment)
            if "errors" in attachment_info:
                return attachment_info

            path = ("/v1/instances/{}/volume_attachments/{}"
                    "?version={}&generation={}".format(instance_info["id"],
                                                       attachment_info["id"],
                                                       self.cfg["version"],
                                                       self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            if data["response"].status != 204:
                return data["data"]

            return resource_deleted()

        except Exception as error:
            print("Error detaching volume with attachment {} from instance"
                  " {}. {}".format(attachment, instance, error))
            raise
示例#16
0
    def delete_binding(self, binding):
        """Delete resource binding

        :param binding: Resource binding name or ID
        :type binding: str
        :return: Delete status
        :rtype: resource_deleted()
        """
        try:
            # Check if binding exists
            binding_info = self.get_resource_binding(binding)
            if "errors" in binding_info:
                return binding_info

            # Connect to api endpoint resource_bindings
            path = ("/v2/resource_bindings/{}".format(binding_info["id"]))

            data = qw("rg", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting resource binding {}. {}".format(
                binding, error))
            raise
    def delete_resource_instance(self, instance):
        """Delete a resource instance

        :param instance: The resource instance name or ID
        :type instance: str
        :return: Deletion status
        :rtype: resource_deleted()
        """
        try:
            instance_info = self.get_resource_instance(instance)
            if "errors" in instance_info:
                return instance_info

            # Connect to api endpoint for resource_instances
            path = ("/v2/resource_instances/{}".format(instance_info['guid']))

            data = qw("rg", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting resource instance. {}".format(error))
示例#18
0
    def delete_vpc(self, vpc):
        """Delete VPC

        :param vpc: VPC name or ID
        :type vpc: str
        :return: Delete status
        :rtype: resource_deleted()
        """
        # Check if VPC exists and get information
        vpc_info = self.get_vpc(vpc)
        if "errors" in vpc_info:
            return vpc_info

        try:
            # Connect to api endpoint for vpcs
            path = ("/v1/vpcs/{}?version={}&generation={}".format(
                vpc_info["id"], self.cfg["version"], self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting VPC {}. {}".format(vpc, error))
            raise
示例#19
0
    def delete_gateway(self, gateway):
        """Delete VPN gateway

        :param gateway: VPN gateway name or ID
        :type gateway: str
        :return: Delete status
        :rtype: dict
        """
        # Check if gateway exists
        gateway_info = self.get_vpn_gateway(gateway)
        if "errors" in gateway_info:
            return gateway_info

        try:
            # Connect to api endpoint for vpn_gateways
            path = ("/v1/vpn_gateways/{}?version={}&generation={}".format(
                gateway_info["id"], self.cfg["version"],
                self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 202:
                return data

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting VPN gateway {}. {}".format(gateway, error))
            raise
示例#20
0
    def release_floating_ip(self, fip):
        """Release floating IP

        :param fip: Floating IP name, ID or address
        :type fip: str
        """
        try:
            # Check if floating IP exists
            fip_info = self.get_floating_ip(fip)
            if "errors" in fip_info:
                return fip_info

            # Connect to api endpoint for floating_ips
            path = ("/v1/floating_ips/{}?version={}&generation={}".format(
                fip_info["id"], self.cfg["version"], self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting floating IP {}. {}".format(fip, error))
            raise
示例#21
0
    def delete_network(self, instance, network):
        """Delete network from cloud instance

        :param instance: Cloud instance ID
        :type instance: str
        :param network: Network name or ID
        :type network: str
        :return: Deletion status
        :rtype: dict
        """
        try:
            ci_info = self.instance.get_instance(instance)
            if "errors" in ci_info:
                return ci_info

            # Check if network exists and retrieve information
            net_info = self.get_network(ci_info["name"], network)
            if "errors" in net_info:
                return net_info

            path = ("/pcloud/v1/cloud-instances/{}/networks/{}".format(
                ci_info["name"], net_info["networkID"]))

            data = qw("power", "DELETE", path, headers())

            # Return data
            if data["response"].status != 200:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting network {} from cloud instance {}."
                  " {}".format(network, instance, error))
示例#22
0
    def delete_task(self, task):
        """Delete task

        :param task: Task ID
        :type task: str
        :return: Deletion status
        :rtype: dict
        """
        # Check if task exists and get information
        task_info = self.get_task(task)
        if "errors" in task_info:
            return task_info

        try:
            # Connect to api endpoint for tasks
            path = ("/pcloud/v1/tasks/{}".format(task_info["taskID"]))

            data = qw("power", "DELETE", path, headers())

            # Return data
            if data["response"].status != 200:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting task {}. {}".format(task, error))
示例#23
0
    def delete_subnet(self, subnet):
        """Delete subnet

        :param subnet: Subnet name or ID
        :type subnet: str
        :return: Delete status
        :rtype: resource_deleted()
        """
        try:
            # Check if subnet exists
            subnet_info = self.get_subnet(subnet)
            if "errors" in subnet_info:
                return subnet_info

            # Connect to api endpoint for subnets
            path = ("/v1/subnets/{}?version={}&generation={}".format(
                subnet_info["id"], self.cfg["version"],
                self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting subnet with name {}. {}".format(
                subnet, error))
            raise
示例#24
0
    def remove_interface_security_group(self, security_group, interface):
        """Remove network interface from a security group

        :param security_group: Security group name or ID
        :type security_group: str
        :parem interface: Interface ID
        :type interface: str
        :return: Delete status
        :rtype: dict
        """
        try:
            # Check if security group exists
            sg_info = self.get_security_group(security_group)
            if "errors" in sg_info:
                return sg_info

            # Connect to api endpoint for security_groups
            path = ("/v1/security_groups/{}/network_interfaces/{}?version={}"
                    "&generation={}".format(sg_info["id"], interface,
                                            self.cfg["version"],
                                            self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error removing network interface {} from security group"
                  " {}. {}".format(interface, security_group, error))
            raise
示例#25
0
    def delete_role(self, role):
        """Delete role

        :param role: Role name or ID
        :type role: str
        :return: Deletion status
        :rtype: dict
        """
        # Check if role exists and get information
        role_info = self.get_role(role)
        if "errors" in role_info:
            return role_info

        try:
            # Connect to api endpoint for roles
            path = ("/v1/roles/{}".format(role_info["id"]))

            data = qw("auth", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting polirolecy {}. {}".format(role, error))
示例#26
0
    def detach_volume(self, **kwargs):
        """Detach volume to a Power Virtual Instance

        :param instance: Instance name or ID
        :type instance: str
        :param pvm: Power Virtual Instance name or ID
        :type pvm: str
        :param volume: Volume name or ID
        :type volume: str
        :return: Dettachement status
        :rtype: dict
        """
        args = ["instance", "pvm", "volume"]
        check_args(args, **kwargs)

        # Build dict of argument and assign default value when needed
        args = {
            'instance': kwargs.get('instance'),
            'pvm': kwargs.get('pvm'),
            'volume': kwargs.get('volume'),
        }

        try:
            # Check if cloud instance exists and retrieve information
            ci_info = self.instance.get_instance(args['instance'])
            if "errors" in ci_info:
                return ci_info

            # Check if pvm exists and retrieve information
            pvm_info = self.pvm.get_pvm(args['instance'], args['pvm'])
            if "errors" in pvm_info:
                return pvm_info

            # Check if volume exists and retrieve information
            vol_info = self.get_volume(ci_info["name"], args["volume"])
            if "errors" in vol_info:
                return vol_info

            # Connect to api endpoint for cloud-instances
            path = ("/pcloud/v1/cloud-instances/{}/pvm-instances/{}"
                    "/volumes/{}".format(ci_info["name"],
                                         pvm_info["pvmInstanceID"],
                                         vol_info["volumeID"]))

            data = qw("power", "DELETE", path, headers())

            # Return data
            if data["response"].status != 202:
                return data["data"]

            # Return status
            payload = {"status": "detached"}
            return resource_deleted(payload)

        except Exception as error:
            print("Error detaching volume {} from Power Virtual Instance {}"
                  " for cloud instance {}. {}".format(args["volume"],
                                                      args['pvm'],
                                                      args['instance'], error))
示例#27
0
    def remove_peer_cidr(self, gateway, connection, prefix_address,
                         prefix_length):
        """Remove peer CIDR from a connection

        :param gateway: VPN gateway name or ID
        :type gateway: str
        :param connection: Connection name or ID
        :type connection: str
        :param prefix_address: The prefix address part of the CIDR
        :type prefix_address: str
        :param prefix_length: The prefix length part of the CIDR
        :type prefix_length: int
        :return: Delete status
        :rtype: dict
        """
        # Retrieve gateway information to get the ID
        gateway_info = self.get_vpn_gateway(gateway)
        if "errors" in gateway_info:
            return gateway_info

        # Retrieve connection information to get the ID
        connection_info = self.get_vpn_gateway_connection(gateway_info["id"],
                                                          connection)
        if "errors" in connection_info:
            return connection_info

        try:
            # Connect to api endpoint for vpn_gateways
            path = ("/v1/vpn_gateways/{}/connections/{}/peer_cidrs/{}/{}"
                    "?version={}&generation={}".format(gateway_info["id"],
                                                       connection_info["id"],
                                                       prefix_address,
                                                       prefix_length,
                                                       self.cfg["version"],
                                                       self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error removing peer CIDR {}/{} in connection {} from VPN"
                  " gateway {}. {}".format(prefix_address, prefix_length,
                                           connection,
                                           gateway, error))
            raise
    def delete_policy(self, lb, listener, policy):
        """Delete policy from listener

        :param lb: Load balancer name or ID
        :type lb: str
        :param listener: Listener port or ID
        :type listener: str
        :param policy: Policy name or ID
        :type policy: str
        :return: Delete status
        :rtype: dict
        """
        # Check if load balancer exists
        lb_info = self.get_lb(lb)
        if "errors" in lb_info:
            return lb_info

        # Check if listener exists
        listener_info = self.get_lb_listener(lb_info["id"], listener)
        if "errors" in listener_info:
            return listener_info

        # Check if policy exists
        policy_info = self.get_lb_listener_policy(lb_info["id"],
                                                  listener_info["id"], policy)
        if "errors" in policy_info:
            return policy_info

        try:
            # Connect to api endpoint for load_balancers
            path = ("/v1/load_balancers/{}/listeners/{}/policies/{}?version={}"
                    "&generation={}".format(lb_info["id"], listener_info["id"],
                                            policy_info["id"],
                                            self.cfg["version"],
                                            self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting policy {} in listener {} from load balancer"
                  " {}. {}".format(policy, listener, lb, error))
            raise
    def delete_member(self, lb, pool, member):
        """Delete member from pool

        :param lb: Load balancer name or ID
        :type lb: str
        :param pool: Pool name ID
        :type pool: str
        :param member: Member address or ID
        :type member: str
        :return: Delete status
        :rtype: dict
        """
        # Check if load balancer exists
        lb_info = self.get_lb(lb)
        if "errors" in lb_info:
            return lb_info

        # Check if pool exists
        pool_info = self.get_lb_pool(lb_info["id"], pool)
        if "errors" in pool_info:
            return pool_info

        # Check if member exists
        member_info = self.get_lb_pool_member(lb_info["id"], pool, member)
        if "errors" in member_info:
            return member_info

        try:
            # Connect to api endpoint for load_balancers
            path = ("/v1/load_balancers/{}/pools/{}/members/{}?version={}"
                    "&generation={}".format(lb_info["id"], pool_info["id"],
                                            member_info["id"],
                                            self.cfg["version"],
                                            self.cfg["generation"]))

            data = qw("iaas", "DELETE", path, headers())

            # Return data
            if data["response"].status != 204:
                return data["data"]

            # Return status
            return resource_deleted()

        except Exception as error:
            print("Error deleting member {} in pool {} from load balancer"
                  " {}. {}".format(member, pool, lb, error))
            raise
示例#30
0
    def delete_objects(self, bucket, objects):
        """Delete objects from the bucket

        :param bucket: Bucket name
        :type bucket: str
        :param objects: List of objects to delete
        :type objects: list
        """
        try:
            for object in objects:
                result = self.client.delete_object(Bucket=bucket, Key=object)
                if result["ResponseMetadata"]["HTTPStatusCode"] != 204:
                    return result

            return resource_deleted()

        except Exception as error:
            return resource_error("unable_to_delete_objects", error)