Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename filter to filter_body for internals #754

Open
vincentsarago opened this issue Sep 24, 2024 · 0 comments
Open

rename filter to filter_body for internals #754

vincentsarago opened this issue Sep 24, 2024 · 0 comments
Labels
enhancement New feature or request needs discussion

Comments

@vincentsarago
Copy link
Member

filter: Annotated[
Optional[str],
Query(
description="""A CQL filter expression for filtering items.\n
Supports `CQL-JSON` as defined in https://portal.ogc.org/files/96288\n
Remember to URL encode the CQL-JSON if using GET""",
json_schema_extra={
"example": "id='LC08_L1TP_060247_20180905_20180912_01_T1_L1TP' AND collection='landsat8_l1tp'", # noqa: E501
},
),
] = attr.ib(default=None)

In ☝️ we use filter which internally can conflict with the python filter method

@attr.s
class FilterExtensionGetRequest(APIRequest):
    """Filter extension GET request model."""

    filter_body: Annotated[
        Optional[str],
        Query(
            alias="filter",
            description="""A CQL filter expression for filtering items.\n
Supports `CQL-JSON` as defined in https://portal.ogc.org/files/96288\n
Remember to URL encode the CQL-JSON if using GET""",
            json_schema_extra={
                "example": "id='LC08_L1TP_060247_20180905_20180912_01_T1_L1TP' AND collection='landsat8_l1tp'",  # noqa: E501
            },
        ),
    ] = attr.ib(default=None)
    ...


class FilterExtensionPostRequest(BaseModel):
    """Filter extension POST request model."""

    filter_body: Optional[Dict[str, Any]] = Field(
        default=None,
        alias="filter",
        description="A CQL filter expression for filtering items.",
        json_schema_extra={
            "example": {
                "op": "and",
                "args": [
                    {
                        "op": "=",
                        "args": [
                            {"property": "id"},
                            "LC08_L1TP_060247_20180905_20180912_01_T1_L1TP",
                        ],
                    },
                    {"op": "=", "args": [{"property": "collection"}, "landsat8_l1tp"]},
                ],
            },
        },
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs discussion
Projects
None yet
Development

No branches or pull requests

1 participant