0
# Configuration Management
1
2
Comprehensive configuration system for Control Service integration including authentication settings, HTTP parameters, service endpoints, and operational options. The configuration system bridges vdk-core configuration with vdk-control-cli requirements.
3
4
## Types
5
6
```python { .api }
7
from vdk.internal.core.config import Configuration, ConfigurationBuilder
8
```
9
10
## Capabilities
11
12
### Configuration Class
13
14
Wrapper class that provides typed access to Control Service configuration values.
15
16
```python { .api }
17
class ControlServiceConfiguration:
18
def __init__(self, config: Configuration) -> None:
19
"""
20
Initialize configuration wrapper.
21
22
Parameters:
23
- config: Configuration - VDK core configuration instance
24
"""
25
26
def api_token(self):
27
"""
28
Get API token for OAuth2 provider.
29
30
Returns:
31
str or None: API token used for authentication
32
"""
33
34
def api_token_authorization_url(self):
35
"""
36
Get API token authorization URL.
37
38
Returns:
39
str or None: OAuth2 provider URL for token exchange
40
"""
41
42
def control_service_rest_api_url(self):
43
"""
44
Get Control Service REST API base URL.
45
46
Returns:
47
str or None: Base REST API URL (e.g., http://server)
48
"""
49
50
def control_sample_job_directory(self):
51
"""
52
Get sample job directory path.
53
54
Returns:
55
str or None: Directory path for sample job creation
56
"""
57
58
def control_http_verify_ssl(self):
59
"""
60
Get SSL verification setting.
61
62
Returns:
63
bool: Whether to verify SSL certificates
64
"""
65
66
def control_http_total_retries(self):
67
"""
68
Get total HTTP retries setting.
69
70
Returns:
71
int or None: Total number of HTTP retries allowed
72
"""
73
74
def control_http_read_retries(self):
75
"""
76
Get read HTTP retries setting.
77
78
Returns:
79
int or None: Number of read retries allowed
80
"""
81
82
def control_http_read_timeout_seconds(self):
83
"""
84
Get read timeout setting.
85
86
Returns:
87
int or None: Read timeout in seconds
88
"""
89
90
def control_http_connect_retries(self):
91
"""
92
Get connection retries setting.
93
94
Returns:
95
int or None: Number of connection retries allowed
96
"""
97
98
def control_http_connect_timeout_seconds(self):
99
"""
100
Get connection timeout setting.
101
102
Returns:
103
int or None: Connection timeout in seconds
104
"""
105
```
106
107
### Configuration Definition
108
109
Function that adds all Control Service configuration definitions to the configuration builder.
110
111
```python { .api }
112
def add_definitions(config_builder: ConfigurationBuilder):
113
"""
114
Add all Control Service configuration definitions.
115
116
Parameters:
117
- config_builder: ConfigurationBuilder - Builder to add configuration options to
118
119
Adds configuration for:
120
- API_TOKEN: OAuth2 refresh token for authentication
121
- API_TOKEN_AUTHORIZATION_URL: OAuth2 provider URL
122
- CONTROL_SERVICE_REST_API_URL: Base REST API URL
123
- CONTROL_SAMPLE_JOB_DIRECTORY: Sample job directory path
124
- CONTROL_HTTP_VERIFY_SSL: SSL verification setting
125
- CONTROL_HTTP_TOTAL_RETRIES: Total HTTP retries
126
- CONTROL_HTTP_READ_RETRIES: Read HTTP retries
127
- CONTROL_HTTP_READ_TIMEOUT_SECONDS: Read timeout
128
- CONTROL_HTTP_CONNECT_RETRIES: Connection retries
129
- CONTROL_HTTP_CONNECT_TIMEOUT_SECONDS: Connection timeout
130
"""
131
```
132
133
## Configuration Keys
134
135
### Authentication Settings
136
137
```python { .api }
138
API_TOKEN = "API_TOKEN"
139
API_TOKEN_AUTHORIZATION_URL = "API_TOKEN_AUTHORIZATION_URL"
140
```
141
142
### Service Settings
143
144
```python { .api }
145
CONTROL_SERVICE_REST_API_URL = "CONTROL_SERVICE_REST_API_URL"
146
CONTROL_SAMPLE_JOB_DIRECTORY = "CONTROL_SAMPLE_JOB_DIRECTORY"
147
```
148
149
### HTTP Settings
150
151
```python { .api }
152
CONTROL_HTTP_VERIFY_SSL = "CONTROL_HTTP_VERIFY_SSL"
153
CONTROL_HTTP_TOTAL_RETRIES = "CONTROL_HTTP_TOTAL_RETRIES"
154
CONTROL_HTTP_READ_RETRIES = "CONTROL_HTTP_READ_RETRIES"
155
CONTROL_HTTP_READ_TIMEOUT_SECONDS = "CONTROL_HTTP_READ_TIMEOUT_SECONDS"
156
CONTROL_HTTP_CONNECT_RETRIES = "CONTROL_HTTP_CONNECT_RETRIES"
157
CONTROL_HTTP_CONNECT_TIMEOUT_SECONDS = "CONTROL_HTTP_CONNECT_TIMEOUT_SECONDS"
158
```
159
160
## Usage Examples
161
162
```python
163
from vdk.internal.core.config import ConfigurationBuilder
164
from vdk.plugin.control_cli_plugin.control_service_configuration import (
165
ControlServiceConfiguration,
166
add_definitions
167
)
168
169
# Add configuration definitions
170
config_builder = ConfigurationBuilder()
171
add_definitions(config_builder)
172
173
# Use configuration in code
174
config = config_builder.build()
175
control_config = ControlServiceConfiguration(config)
176
177
# Access configuration values
178
api_url = control_config.control_service_rest_api_url()
179
verify_ssl = control_config.control_http_verify_ssl()
180
api_token = control_config.api_token()
181
182
if api_url and api_token:
183
print(f"Connecting to {api_url} with SSL verification: {verify_ssl}")
184
```
185
186
## Configuration via Environment Variables
187
188
The plugin automatically sets environment variables for vdk-control-cli integration:
189
190
```bash
191
# Authentication
192
export VDK_API_TOKEN="your-api-token"
193
export VDK_API_TOKEN_AUTHORIZATION_URL="https://auth.example.com/oauth/token"
194
195
# Service endpoint
196
export VDK_CONTROL_SERVICE_REST_API_URL="https://api.example.com"
197
198
# HTTP settings
199
export VDK_CONTROL_HTTP_VERIFY_SSL="true"
200
export VDK_CONTROL_HTTP_TOTAL_RETRIES="3"
201
export VDK_CONTROL_HTTP_CONNECT_TIMEOUT_SECONDS="30"
202
```
203
204
## Configuration Validation
205
206
Configuration values are validated during plugin initialization:
207
208
- **API_TOKEN**: Required for authenticated operations
209
- **CONTROL_SERVICE_REST_API_URL**: Required for API calls
210
- **HTTP settings**: Validated for reasonable values
211
- **Timeouts**: Must be positive integers
212
- **SSL verification**: Boolean values only