def _bucket_response_get(self, bucket_name, querystring):
    self._set_action('BUCKET', 'GET', querystring)
    self._authenticate_and_authorize_s3_action()
    if ('object-lock' in querystring):
        (lock_enabled, mode, days, years) = self.backend.get_object_lock_configuration(bucket_name)
        template = self.response_template(S3_BUCKET_LOCK_CONFIGURATION)
        return template.render(lock_enabled=lock_enabled, mode=mode, days=days, years=years)
    if ('uploads' in querystring):
        for unsup in ('delimiter', 'max-uploads'):
            if (unsup in querystring):
                raise NotImplementedError('Listing multipart uploads with {} has not been implemented yet.'.format(unsup))
        multiparts = list(self.backend.get_all_multiparts(bucket_name).values())
        if ('prefix' in querystring):
            prefix = querystring.get('prefix', [None])[0]
            multiparts = [upload for upload in multiparts if upload.key_name.startswith(prefix)]
        template = self.response_template(S3_ALL_MULTIPARTS)
        return template.render(bucket_name=bucket_name, uploads=multiparts)
    elif ('location' in querystring):
        location = self.backend.get_bucket_location(bucket_name)
        template = self.response_template(S3_BUCKET_LOCATION)
        if (location == DEFAULT_REGION_NAME):
            location = None
        return template.render(location=location)
    elif ('lifecycle' in querystring):
        rules = self.backend.get_bucket_lifecycle(bucket_name)
        if (not rules):
            template = self.response_template(S3_NO_LIFECYCLE)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_BUCKET_LIFECYCLE_CONFIGURATION)
        return template.render(rules=rules)
    elif ('versioning' in querystring):
        versioning = self.backend.get_bucket_versioning(bucket_name)
        template = self.response_template(S3_BUCKET_GET_VERSIONING)
        return template.render(status=versioning)
    elif ('policy' in querystring):
        policy = self.backend.get_bucket_policy(bucket_name)
        if (not policy):
            template = self.response_template(S3_NO_POLICY)
            return (404, {}, template.render(bucket_name=bucket_name))
        return (200, {}, policy)
    elif ('website' in querystring):
        website_configuration = self.backend.get_bucket_website_configuration(bucket_name)
        if (not website_configuration):
            template = self.response_template(S3_NO_BUCKET_WEBSITE_CONFIG)
            return (404, {}, template.render(bucket_name=bucket_name))
        return (200, {}, website_configuration)
    elif ('acl' in querystring):
        acl = self.backend.get_bucket_acl(bucket_name)
        template = self.response_template(S3_OBJECT_ACL_RESPONSE)
        return template.render(acl=acl)
    elif ('tagging' in querystring):
        tags = self.backend.get_bucket_tagging(bucket_name)['Tags']
        if (len(tags) == 0):
            template = self.response_template(S3_NO_BUCKET_TAGGING)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_OBJECT_TAGGING_RESPONSE)
        return template.render(tags=tags)
    elif ('logging' in querystring):
        logging = self.backend.get_bucket_logging(bucket_name)
        if (not logging):
            template = self.response_template(S3_NO_LOGGING_CONFIG)
            return (200, {}, template.render())
        template = self.response_template(S3_LOGGING_CONFIG)
        return (200, {}, template.render(logging=logging))
    elif ('cors' in querystring):
        cors = self.backend.get_bucket_cors(bucket_name)
        if (len(cors) == 0):
            template = self.response_template(S3_NO_CORS_CONFIG)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_BUCKET_CORS_RESPONSE)
        return template.render(cors=cors)
    elif ('notification' in querystring):
        notification_configuration = self.backend.get_bucket_notification_configuration(bucket_name)
        if (not notification_configuration):
            return (200, {}, '')
        template = self.response_template(S3_GET_BUCKET_NOTIFICATION_CONFIG)
        return template.render(config=notification_configuration)
    elif ('accelerate' in querystring):
        bucket = self.backend.get_bucket(bucket_name)
        if (bucket.accelerate_configuration is None):
            template = self.response_template(S3_BUCKET_ACCELERATE_NOT_SET)
            return (200, {}, template.render())
        template = self.response_template(S3_BUCKET_ACCELERATE)
        return template.render(bucket=bucket)
    elif ('publicAccessBlock' in querystring):
        public_block_config = self.backend.get_public_access_block(bucket_name)
        template = self.response_template(S3_PUBLIC_ACCESS_BLOCK_CONFIGURATION)
        return template.render(public_block_config=public_block_config)
    elif ('versions' in querystring):
        delimiter = querystring.get('delimiter', [None])[0]
        encoding_type = querystring.get('encoding-type', [None])[0]
        key_marker = querystring.get('key-marker', [None])[0]
        max_keys = querystring.get('max-keys', [None])[0]
        prefix = querystring.get('prefix', [''])[0]
        version_id_marker = querystring.get('version-id-marker', [None])[0]
        bucket = self.backend.get_bucket(bucket_name)
        (versions, common_prefixes, delete_markers) = self.backend.list_object_versions(bucket_name, delimiter=delimiter, encoding_type=encoding_type, key_marker=key_marker, max_keys=max_keys, version_id_marker=version_id_marker, prefix=prefix)
        key_list = versions
        template = self.response_template(S3_BUCKET_GET_VERSIONS)
        return (200, {}, template.render(common_prefixes=common_prefixes, key_list=key_list, delete_marker_list=delete_markers, bucket=bucket, prefix=prefix, max_keys=1000, delimiter=delimiter, key_marker=key_marker, is_truncated='false'))
    elif ('encryption' in querystring):
        encryption = self.backend.get_bucket_encryption(bucket_name)
        if (not encryption):
            template = self.response_template(S3_NO_ENCRYPTION)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_ENCRYPTION_CONFIG)
        return (200, {}, template.render(encryption=encryption))
    elif (querystring.get('list-type', [None])[0] == '2'):
        return (200, {}, self._handle_list_objects_v2(bucket_name, querystring))
    bucket = self.backend.get_bucket(bucket_name)
    prefix = querystring.get('prefix', [None])[0]
    if (prefix and isinstance(prefix, bytes)):
        prefix = prefix.decode('utf-8')
    delimiter = querystring.get('delimiter', [None])[0]
    max_keys = int(querystring.get('max-keys', [1000])[0])
    marker = querystring.get('marker', [None])[0]
    (result_keys, result_folders) = self.backend.list_objects(bucket, prefix, delimiter)
    if marker:
        result_keys = self._get_results_from_token(result_keys, marker)
    (result_keys, is_truncated, next_marker) = self._truncate_result(result_keys, max_keys)
    template = self.response_template(S3_BUCKET_GET_RESPONSE)
    return (200, {}, template.render(bucket=bucket, prefix=prefix, delimiter=delimiter, result_keys=result_keys, result_folders=result_folders, is_truncated=is_truncated, next_marker=next_marker, max_keys=max_keys))
def _bucket_response_get(self, bucket_name, querystring):
    self._set_action('BUCKET', 'GET', querystring)
    self._authenticate_and_authorize_s3_action()
    if ('object-lock' in querystring):
        (lock_enabled, mode, days, years) = self.backend.get_object_lock_configuration(bucket_name)
        template = self.response_template(S3_BUCKET_LOCK_CONFIGURATION)
        return template.render(lock_enabled=lock_enabled, mode=mode, days=days, years=years)
    if ('uploads' in querystring):
        for unsup in ('delimiter', 'max-uploads'):
            if (unsup in querystring):
                raise NotImplementedError('Listing multipart uploads with {} has not been implemented yet.'.format(unsup))
        multiparts = list(self.backend.get_all_multiparts(bucket_name).values())
        if ('prefix' in querystring):
            prefix = querystring.get('prefix', [None])[0]
            multiparts = [upload for upload in multiparts if upload.key_name.startswith(prefix)]
        template = self.response_template(S3_ALL_MULTIPARTS)
        return template.render(bucket_name=bucket_name, uploads=multiparts)
    elif ('location' in querystring):
        location = self.backend.get_bucket_location(bucket_name)
        template = self.response_template(S3_BUCKET_LOCATION)
        if (location == DEFAULT_REGION_NAME):
            location = None
        return template.render(location=location)
    elif ('lifecycle' in querystring):
        rules = self.backend.get_bucket_lifecycle(bucket_name)
        if (not rules):
            template = self.response_template(S3_NO_LIFECYCLE)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_BUCKET_LIFECYCLE_CONFIGURATION)
        return template.render(rules=rules)
    elif ('versioning' in querystring):
        versioning = self.backend.get_bucket_versioning(bucket_name)
        template = self.response_template(S3_BUCKET_GET_VERSIONING)
        return template.render(status=versioning)
    elif ('policy' in querystring):
        policy = self.backend.get_bucket_policy(bucket_name)
        if (not policy):
            template = self.response_template(S3_NO_POLICY)
            return (404, {}, template.render(bucket_name=bucket_name))
        return (200, {}, policy)
    elif ('website' in querystring):
        website_configuration = self.backend.get_bucket_website_configuration(bucket_name)
        if (not website_configuration):
            template = self.response_template(S3_NO_BUCKET_WEBSITE_CONFIG)
            return (404, {}, template.render(bucket_name=bucket_name))
        return (200, {}, website_configuration)
    elif ('acl' in querystring):
        acl = self.backend.get_bucket_acl(bucket_name)
        template = self.response_template(S3_OBJECT_ACL_RESPONSE)
        return template.render(acl=acl)
    elif ('tagging' in querystring):
        tags = self.backend.get_bucket_tagging(bucket_name)['Tags']
        if (len(tags) == 0):
            template = self.response_template(S3_NO_BUCKET_TAGGING)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_OBJECT_TAGGING_RESPONSE)
        return template.render(tags=tags)
    elif ('logging' in querystring):
        logging = self.backend.get_bucket_logging(bucket_name)
        if (not logging):
            template = self.response_template(S3_NO_LOGGING_CONFIG)
            return (200, {}, template.render())
        template = self.response_template(S3_LOGGING_CONFIG)
        return (200, {}, template.render(logging=logging))
    elif ('cors' in querystring):
        cors = self.backend.get_bucket_cors(bucket_name)
        if (len(cors) == 0):
            template = self.response_template(S3_NO_CORS_CONFIG)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_BUCKET_CORS_RESPONSE)
        return template.render(cors=cors)
    elif ('notification' in querystring):
        notification_configuration = self.backend.get_bucket_notification_configuration(bucket_name)
        if (not notification_configuration):
            return (200, {}, )
        template = self.response_template(S3_GET_BUCKET_NOTIFICATION_CONFIG)
        return template.render(config=notification_configuration)
    elif ('accelerate' in querystring):
        bucket = self.backend.get_bucket(bucket_name)
        if (bucket.accelerate_configuration is None):
            template = self.response_template(S3_BUCKET_ACCELERATE_NOT_SET)
            return (200, {}, template.render())
        template = self.response_template(S3_BUCKET_ACCELERATE)
        return template.render(bucket=bucket)
    elif ('publicAccessBlock' in querystring):
        public_block_config = self.backend.get_public_access_block(bucket_name)
        template = self.response_template(S3_PUBLIC_ACCESS_BLOCK_CONFIGURATION)
        return template.render(public_block_config=public_block_config)
    elif ('versions' in querystring):
        delimiter = querystring.get('delimiter', [None])[0]
        encoding_type = querystring.get('encoding-type', [None])[0]
        key_marker = querystring.get('key-marker', [None])[0]
        max_keys = querystring.get('max-keys', [None])[0]
        prefix = querystring.get('prefix', [])[0]
        version_id_marker = querystring.get('version-id-marker', [None])[0]
        bucket = self.backend.get_bucket(bucket_name)
        (versions, common_prefixes, delete_markers) = self.backend.list_object_versions(bucket_name, delimiter=delimiter, encoding_type=encoding_type, key_marker=key_marker, max_keys=max_keys, version_id_marker=version_id_marker, prefix=prefix)
        key_list = versions
        template = self.response_template(S3_BUCKET_GET_VERSIONS)
        return (200, {}, template.render(common_prefixes=common_prefixes, key_list=key_list, delete_marker_list=delete_markers, bucket=bucket, prefix=prefix, max_keys=1000, delimiter=delimiter, key_marker=key_marker, is_truncated='false'))
    elif ('encryption' in querystring):
        encryption = self.backend.get_bucket_encryption(bucket_name)
        if (not encryption):
            template = self.response_template(S3_NO_ENCRYPTION)
            return (404, {}, template.render(bucket_name=bucket_name))
        template = self.response_template(S3_ENCRYPTION_CONFIG)
        return (200, {}, template.render(encryption=encryption))
    elif (querystring.get('list-type', [None])[0] == '2'):
        return (200, {}, self._handle_list_objects_v2(bucket_name, querystring))
    bucket = self.backend.get_bucket(bucket_name)
    prefix = querystring.get('prefix', [None])[0]
    if (prefix and isinstance(prefix, bytes)):
        prefix = prefix.decode('utf-8')
    delimiter = querystring.get('delimiter', [None])[0]
    max_keys = int(querystring.get('max-keys', [1000])[0])
    marker = querystring.get('marker', [None])[0]
    (result_keys, result_folders) = self.backend.list_objects(bucket, prefix, delimiter)
    if marker:
        result_keys = self._get_results_from_token(result_keys, marker)
    (result_keys, is_truncated, next_marker) = self._truncate_result(result_keys, max_keys)
    template = self.response_template(S3_BUCKET_GET_RESPONSE)
    return (200, {}, template.render(bucket=bucket, prefix=prefix, delimiter=delimiter, result_keys=result_keys, result_folders=result_folders, is_truncated=is_truncated, next_marker=next_marker, max_keys=max_keys))