Source code for airflow.providers.fab.auth_manager.api_fastapi.datamodels.users

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations

from pydantic import Field, SecretStr

from airflow.api_fastapi.common.types import UtcDateTime
from airflow.api_fastapi.core_api.base import BaseModel, StrictBaseModel
from airflow.providers.fab.auth_manager.api_fastapi.datamodels.roles import Role


[docs] class UserBody(StrictBaseModel): """Incoming payload for creating a user."""
[docs] username: str = Field(min_length=1)
[docs] email: str = Field(min_length=1)
[docs] first_name: str = Field(min_length=1)
[docs] last_name: str = Field(min_length=1)
[docs] roles: list[Role] | None = None
[docs] password: SecretStr
[docs] class UserPatchBody(StrictBaseModel): """Incoming payload for updating a user (all fields optional)."""
[docs] username: str | None = Field(default=None, min_length=1)
[docs] email: str | None = Field(default=None, min_length=1)
[docs] first_name: str | None = Field(default=None, min_length=1)
[docs] last_name: str | None = Field(default=None, min_length=1)
[docs] roles: list[Role] | None = None
[docs] password: SecretStr | None = None
[docs] class UserResponse(BaseModel): """Outgoing representation of a user (no password)."""
[docs] username: str
[docs] email: str
[docs] first_name: str
[docs] last_name: str
[docs] roles: list[Role] | None = None
[docs] active: bool | None = None
[docs] last_login: UtcDateTime | None = None
[docs] login_count: int | None = None
[docs] fail_login_count: int | None = None
[docs] created_on: UtcDateTime | None = None
[docs] changed_on: UtcDateTime | None = None
[docs] class UserCollectionResponse(BaseModel): """Response model for a collection of users."""
[docs] users: list[UserResponse]
[docs] total_entries: int

Was this entry helpful?