0
# Main Source Interface
1
2
The primary connector interface providing connection testing and stream discovery functionality. SourceRkiCovid is the main entry point that manages all available data streams and validates connectivity.
3
4
## Capabilities
5
6
### Source Class
7
8
Main source connector class that coordinates access to all RKI COVID-19 data streams.
9
10
```python { .api }
11
class SourceRkiCovid(AbstractSource):
12
"""
13
Main source connector for RKI COVID-19 data.
14
15
Inherits from airbyte_cdk.sources.AbstractSource and provides
16
standardized Airbyte connector functionality.
17
"""
18
```
19
20
### Connection Testing
21
22
Validates connectivity to the RKI COVID-19 API before attempting data synchronization.
23
24
```python { .api }
25
def check_connection(self, logger, config) -> Tuple[bool, any]:
26
"""
27
Test connection availability for the connector.
28
29
Parameters:
30
- logger: Logger object for recording connection test results
31
- config: User-input configuration object conforming to spec.json
32
33
Returns:
34
Tuple[bool, any]: (True, None) if connection successful,
35
(False, error_message) if connection fails
36
37
Implementation:
38
Tests connectivity by making a GET request to the Germany endpoint
39
at https://api.corona-zahlen.org/germany and checking for 200 status.
40
"""
41
```
42
43
### Stream Discovery
44
45
Returns the complete list of all 16 available data streams configured with the provided settings.
46
47
```python { .api }
48
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
49
"""
50
Discover and return all available data streams.
51
52
Parameters:
53
- config: User configuration mapping containing start_date
54
55
Returns:
56
List[Stream]: List of 16 configured stream objects including:
57
- 4 current data streams (full-refresh)
58
- 6 historical Germany streams (incremental)
59
- 6 state historical streams (full-refresh)
60
61
Stream Categories:
62
- Germany current statistics
63
- Germany age groups
64
- Germany states current statistics
65
- Germany states age groups
66
- Historical Germany data (cases, deaths, recovered, incidence, frozen incidence, hospitalization)
67
- Historical states data (same metrics as Germany historical)
68
"""
69
```
70
71
## Usage Examples
72
73
### Basic Source Initialization
74
75
```python
76
from source_rki_covid import SourceRkiCovid
77
78
# Create source instance
79
source = SourceRkiCovid()
80
81
# Minimal configuration
82
config = {
83
"start_date": "2023-01-01"
84
}
85
```
86
87
### Connection Testing
88
89
```python
90
# Test connection before running sync
91
is_valid, error = source.check_connection(logger=None, config=config)
92
93
if is_valid:
94
print("Connection successful!")
95
else:
96
print(f"Connection failed: {error}")
97
```
98
99
### Stream Discovery
100
101
```python
102
# Get all available streams
103
streams = source.streams(config)
104
105
print(f"Total streams: {len(streams)}") # 16 streams
106
107
# Examine stream types
108
for stream in streams:
109
print(f"Stream: {stream.__class__.__name__}")
110
print(f"Primary key: {stream.primary_key}")
111
112
# Check if incremental
113
if hasattr(stream, 'cursor_field'):
114
print(f"Cursor field: {stream.cursor_field}")
115
```
116
117
## Dependencies
118
119
- **airbyte_cdk.sources.AbstractSource**: Base class providing standard connector interface
120
- **requests**: HTTP client for API communication (used internally)
121
- **RKI COVID API**: External API at https://api.corona-zahlen.org/