Delete objects in a given S3 bucket.

    Returns {deleted: true} if all objects were deleted
    and {deleted: false, failed: [key, ...]} otherwise

    CLI Example:

    .. code-block:: bash

        salt myminion boto_s3_bucket.delete_objects mybucket '{Objects: [Key: myobject]}'

def delete_objects(Bucket, Delete, MFA=None, RequestPayer=None,
                   region=None, key=None, keyid=None, profile=None):
    '''
    Delete objects in a given S3 bucket.

    Returns {deleted: true} if all objects were deleted
    and {deleted: false, failed: [key, ...]} otherwise

    CLI Example:

    .. code-block:: bash

        salt myminion boto_s3_bucket.delete_objects mybucket '{Objects: [Key: myobject]}'

    '''

    if isinstance(Delete, six.string_types):
        Delete = salt.utils.json.loads(Delete)
    if not isinstance(Delete, dict):
        raise SaltInvocationError("Malformed Delete request.")
    if 'Objects' not in Delete:
        raise SaltInvocationError("Malformed Delete request.")

    failed = []
    objs = Delete['Objects']
    for i in range(0, len(objs), 1000):
        chunk = objs[i:i+1000]
        subset = {'Objects': chunk, 'Quiet': True}
        try:
            args = {'Bucket': Bucket}
            args.update({'MFA': MFA}) if MFA else None
            args.update({'RequestPayer': RequestPayer}) if RequestPayer else None
            args.update({'Delete': subset})
            conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
            ret = conn.delete_objects(**args)
            failed += ret.get('Errors', [])
        except ClientError as e:
            return {'deleted': False, 'error': __utils__['boto3.get_error'](e)}

    if failed:
        return {'deleted': False, 'failed': failed}
    else:
        return {'deleted': True}