(func)
return wrapper
A decorator that protects instances that are not owned by a particular AWSResourceGroup from being modified

    It is assumed that the decorated function takes a list of instance IDs as its first argument; this list
    is modified before the decorated function is called to strip out any unowned instances.  In this case a warning
    is logged.
A decorator that protects instances that are not owned by a particular AWSResourceGroup from being modified
A decorator that protects instances that are not owned by a particular AWSResourceGroup from being modified
def protect_unowned_instances(func):
    """ A decorator that protects instances that are not owned by a particular AWSResourceGroup from being modified

    It is assumed that the decorated function takes a list of instance IDs as its first argument; this list
    is modified before the decorated function is called to strip out any unowned instances.  In this case a warning
    is logged.
    """

    def wrapper(self, instance_ids, *args, **kwargs):
        resource_group_instances = list(set(instance_ids) & set(self.instance_ids))
        invalid_instances = set(instance_ids) - set(self.instance_ids)
        if invalid_instances:
            logger.warning(f"Some instances are not part of this resource group ({self.id}):\n{invalid_instances}")
        return func(self, resource_group_instances, *args, **kwargs)

    return wrapper
def protect_unowned_instances ( func ) : def wrapper ( self , instance_ids , * args , * * kwargs ) : resource_group_instances = list ( set ( instance_ids ) & set ( self . instance_ids ) ) invalid_instances = set ( instance_ids ) - set ( self . instance_ids ) if invalid_instances : logger . warning ( f"Some instances are not part of this resource group ({self.id}):\n{invalid_instances}" ) return func ( self , resource_group_instances , * args , * * kwargs ) return wrapper