Coverage for /home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/core_api/routes/public/providers.py: 95%

17 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 14:22 +0000

1# Licensed to the Apache Software Foundation (ASF) under one 

2# or more contributor license agreements. See the NOTICE file 

3# distributed with this work for additional information 

4# regarding copyright ownership. The ASF licenses this file 

5# to you under the Apache License, Version 2.0 (the 

6# "License"); you may not use this file except in compliance 

7# with the License. You may obtain a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, 

12# software distributed under the License is distributed on an 

13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 

14# KIND, either express or implied. See the License for the 

15# specific language governing permissions and limitations 

16# under the License. 

17 

18from __future__ import annotations 

19 

20from fastapi import Depends 

21 

22from airflow.api_fastapi.auth.managers.models.resource_details import AccessView 

23from airflow.api_fastapi.common.parameters import QueryLimit, QueryOffset 

24from airflow.api_fastapi.common.router import AirflowRouter 

25from airflow.api_fastapi.core_api.datamodels.providers import ProviderCollectionResponse 

26from airflow.api_fastapi.core_api.security import requires_access_view 

27from airflow.api_fastapi.core_api.services.public.providers import _provider_mapper 

28from airflow.providers_manager import ProvidersManager 

29 

30providers_router = AirflowRouter(tags=["Provider"], prefix="/providers") 

31 

32 

33@providers_router.get( 

34 "", 

35 dependencies=[Depends(requires_access_view(AccessView.PROVIDERS))], 

36) 

37def get_providers( 

38 limit: QueryLimit, 

39 offset: QueryOffset, 

40) -> ProviderCollectionResponse: 

41 """Get providers.""" 

42 providers = sorted( 

43 [_provider_mapper(d) for d in ProvidersManager().providers.values()], key=lambda x: x.package_name 

44 ) 

45 total_entries = len(providers) 

46 

47 if limit.value is not None and offset.value is not None: 47 ↛ 49line 47 didn't jump to line 49 because the condition on line 47 was always true

48 providers = providers[offset.value : offset.value + limit.value] 

49 return ProviderCollectionResponse(providers=providers, total_entries=total_entries)