# Copyright (c) 2023 CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to legal@cloudzero.com

from dataclasses import dataclass
from typing import Dict, Optional

from toolz.curried import valfilter

filter_none = valfilter(lambda v: v is not None)


@dataclass(frozen=True)
class RequiredQueryMetadata:
    query_type: str
    organization_id: Optional[str] = None


def get_metadata(required_query_metadata: RequiredQueryMetadata, *,
                 extra: Optional[Dict[str, str]] = None) -> Dict[str, str]:
    return filter_none({
        **required_query_metadata.__dict__,
        **(extra or {})
    })  # type: ignore
