elastly 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. elastly/__init__.py +117 -0
  2. elastly/api/__init__.py +7 -0
  3. elastly/api/ingest_api.py +1167 -0
  4. elastly/api/prices_api.py +349 -0
  5. elastly/api/writebacks_api.py +618 -0
  6. elastly/api_client.py +805 -0
  7. elastly/api_response.py +21 -0
  8. elastly/configuration.py +606 -0
  9. elastly/exceptions.py +219 -0
  10. elastly/models/__init__.py +49 -0
  11. elastly/models/ack_writebacks_response.py +94 -0
  12. elastly/models/api_error.py +93 -0
  13. elastly/models/api_error_error.py +102 -0
  14. elastly/models/batch_created_response.py +91 -0
  15. elastly/models/batch_status_response.py +110 -0
  16. elastly/models/claim_writebacks_request.py +90 -0
  17. elastly/models/claim_writebacks_response.py +97 -0
  18. elastly/models/claim_writebacks_response_tasks_inner.py +122 -0
  19. elastly/models/commit_batch_response.py +89 -0
  20. elastly/models/prices_request.py +98 -0
  21. elastly/models/prices_request_lines_inner.py +114 -0
  22. elastly/models/prices_response.py +97 -0
  23. elastly/models/prices_response_lines_inner.py +138 -0
  24. elastly/models/prices_response_lines_inner_one_of.py +131 -0
  25. elastly/models/prices_response_lines_inner_one_of1.py +105 -0
  26. elastly/models/prices_response_lines_inner_one_of_explanation.py +121 -0
  27. elastly/models/prices_response_lines_inner_one_of_explanation_drivers_inner.py +102 -0
  28. elastly/models/prices_response_lines_inner_one_of_reason_inner.py +95 -0
  29. elastly/models/stage_records_request.py +166 -0
  30. elastly/models/stage_records_request_one_of.py +107 -0
  31. elastly/models/stage_records_request_one_of1.py +107 -0
  32. elastly/models/stage_records_request_one_of1_records_inner.py +126 -0
  33. elastly/models/stage_records_request_one_of2.py +107 -0
  34. elastly/models/stage_records_request_one_of2_records_inner.py +160 -0
  35. elastly/models/stage_records_request_one_of2_records_inner_lines_inner.py +119 -0
  36. elastly/models/stage_records_request_one_of3.py +107 -0
  37. elastly/models/stage_records_request_one_of3_records_inner.py +131 -0
  38. elastly/models/stage_records_request_one_of3_records_inner_lines_inner.py +98 -0
  39. elastly/models/stage_records_request_one_of_records_inner.py +118 -0
  40. elastly/models/stage_records_response.py +90 -0
  41. elastly/models/writeback_ack_request.py +98 -0
  42. elastly/models/writeback_ack_request_results_inner.py +93 -0
  43. elastly/py.typed +0 -0
  44. elastly/rest.py +264 -0
  45. elastly-0.1.0.dist-info/METADATA +100 -0
  46. elastly-0.1.0.dist-info/RECORD +49 -0
  47. elastly-0.1.0.dist-info/WHEEL +5 -0
  48. elastly-0.1.0.dist-info/licenses/LICENSE +21 -0
  49. elastly-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,606 @@
1
+ """
2
+ Elastly API
3
+
4
+ Elastly public API v1: price serving, canonical ingest, write-back claims and webhooks. Authenticate every request with an API key: Authorization: Bearer elastly_live_...
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@elastly.io
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ import copy
15
+ import http.client as httplib
16
+ import logging
17
+ from logging import FileHandler
18
+ import multiprocessing
19
+ import sys
20
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
21
+ from typing_extensions import NotRequired, Self
22
+
23
+ import urllib3
24
+
25
+
26
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
27
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
28
+ 'minimum', 'exclusiveMinimum', 'maxLength',
29
+ 'minLength', 'pattern', 'maxItems', 'minItems'
30
+ }
31
+
32
+ ServerVariablesT = Dict[str, str]
33
+
34
+ GenericAuthSetting = TypedDict(
35
+ "GenericAuthSetting",
36
+ {
37
+ "type": str,
38
+ "in": str,
39
+ "key": str,
40
+ "value": str,
41
+ },
42
+ )
43
+
44
+
45
+ OAuth2AuthSetting = TypedDict(
46
+ "OAuth2AuthSetting",
47
+ {
48
+ "type": Literal["oauth2"],
49
+ "in": Literal["header"],
50
+ "key": Literal["Authorization"],
51
+ "value": str,
52
+ },
53
+ )
54
+
55
+
56
+ APIKeyAuthSetting = TypedDict(
57
+ "APIKeyAuthSetting",
58
+ {
59
+ "type": Literal["api_key"],
60
+ "in": str,
61
+ "key": str,
62
+ "value": Optional[str],
63
+ },
64
+ )
65
+
66
+
67
+ BasicAuthSetting = TypedDict(
68
+ "BasicAuthSetting",
69
+ {
70
+ "type": Literal["basic"],
71
+ "in": Literal["header"],
72
+ "key": Literal["Authorization"],
73
+ "value": Optional[str],
74
+ },
75
+ )
76
+
77
+
78
+ BearerFormatAuthSetting = TypedDict(
79
+ "BearerFormatAuthSetting",
80
+ {
81
+ "type": Literal["bearer"],
82
+ "in": Literal["header"],
83
+ "format": Literal["JWT"],
84
+ "key": Literal["Authorization"],
85
+ "value": str,
86
+ },
87
+ )
88
+
89
+
90
+ BearerAuthSetting = TypedDict(
91
+ "BearerAuthSetting",
92
+ {
93
+ "type": Literal["bearer"],
94
+ "in": Literal["header"],
95
+ "key": Literal["Authorization"],
96
+ "value": str,
97
+ },
98
+ )
99
+
100
+
101
+ HTTPSignatureAuthSetting = TypedDict(
102
+ "HTTPSignatureAuthSetting",
103
+ {
104
+ "type": Literal["http-signature"],
105
+ "in": Literal["header"],
106
+ "key": Literal["Authorization"],
107
+ "value": None,
108
+ },
109
+ )
110
+
111
+
112
+ AuthSettings = TypedDict(
113
+ "AuthSettings",
114
+ {
115
+ "apiKey": BearerAuthSetting,
116
+ },
117
+ total=False,
118
+ )
119
+
120
+
121
+ class HostSettingVariable(TypedDict):
122
+ description: str
123
+ default_value: str
124
+ enum_values: List[str]
125
+
126
+
127
+ class HostSetting(TypedDict):
128
+ url: str
129
+ description: str
130
+ variables: NotRequired[Dict[str, HostSettingVariable]]
131
+
132
+
133
+ class Configuration:
134
+ """This class contains various settings of the API client.
135
+
136
+ :param host: Base url.
137
+ :param ignore_operation_servers
138
+ Boolean to ignore operation servers for the API client.
139
+ Config will use `host` as the base url regardless of the operation servers.
140
+ :param api_key: Dict to store API key(s).
141
+ Each entry in the dict specifies an API key.
142
+ The dict key is the name of the security scheme in the OAS specification.
143
+ The dict value is the API key secret.
144
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
145
+ The dict key is the name of the security scheme in the OAS specification.
146
+ The dict value is an API key prefix when generating the auth data.
147
+ :param username: Username for HTTP basic authentication.
148
+ :param password: Password for HTTP basic authentication.
149
+ :param access_token: Access token.
150
+ :param server_index: Index to servers configuration.
151
+ :param server_variables: Mapping with string values to replace variables in
152
+ templated server configuration. The validation of enums is performed for
153
+ variables with defined enum values before.
154
+ :param server_operation_index: Mapping from operation ID to an index to server
155
+ configuration.
156
+ :param server_operation_variables: Mapping from operation ID to a mapping with
157
+ string values to replace variables in templated server configuration.
158
+ The validation of enums is performed for variables with defined enum
159
+ values before.
160
+ :param verify_ssl: bool - Set this to false to skip verifying SSL certificate
161
+ when calling API from https server.
162
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
163
+ in PEM format.
164
+ :param retries: int | urllib3.util.retry.Retry - Retry configuration.
165
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
166
+ in PEM (str) or DER (bytes) format.
167
+ :param cert_file: the path to a client certificate file, for mTLS.
168
+ :param key_file: the path to a client key file, for mTLS.
169
+ :param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
170
+ :param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
171
+ :param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync.
172
+ :param proxy: Proxy URL.
173
+ :param proxy_headers: Proxy headers.
174
+ :param safe_chars_for_path_param: Safe characters for path parameter encoding.
175
+ :param client_side_validation: Enable client-side validation. Default True.
176
+ :param socket_options: Options to pass down to the underlying urllib3 socket.
177
+ :param datetime_format: Datetime format string for serialization.
178
+ :param date_format: Date format string for serialization.
179
+
180
+ :Example:
181
+ """
182
+
183
+ _default: ClassVar[Optional[Self]] = None
184
+
185
+ def __init__(
186
+ self,
187
+ host: Optional[str]=None,
188
+ api_key: Optional[Dict[str, str]]=None,
189
+ api_key_prefix: Optional[Dict[str, str]]=None,
190
+ username: Optional[str]=None,
191
+ password: Optional[str]=None,
192
+ access_token: Optional[str]=None,
193
+ server_index: Optional[int]=None,
194
+ server_variables: Optional[ServerVariablesT]=None,
195
+ server_operation_index: Optional[Dict[int, int]]=None,
196
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
197
+ ignore_operation_servers: bool=False,
198
+ ssl_ca_cert: Optional[str]=None,
199
+ retries: Optional[Union[int, urllib3.util.retry.Retry]] = None,
200
+ ca_cert_data: Optional[Union[str, bytes]] = None,
201
+ cert_file: Optional[str]=None,
202
+ key_file: Optional[str]=None,
203
+ verify_ssl: bool=True,
204
+ assert_hostname: Optional[bool]=None,
205
+ tls_server_name: Optional[str]=None,
206
+ connection_pool_maxsize: Optional[int]=None,
207
+ proxy: Optional[str]=None,
208
+ proxy_headers: Optional[Any]=None,
209
+ safe_chars_for_path_param: str='',
210
+ client_side_validation: bool=True,
211
+ socket_options: Optional[Any]=None,
212
+ datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
213
+ date_format: str="%Y-%m-%d",
214
+ *,
215
+ debug: Optional[bool] = None,
216
+ ) -> None:
217
+ """Constructor
218
+ """
219
+ self._base_path = "https://app.elastly.io" if host is None else host
220
+ """Default Base url
221
+ """
222
+ self.server_index = 0 if server_index is None and host is None else server_index
223
+ self.server_operation_index = server_operation_index or {}
224
+ """Default server index
225
+ """
226
+ self.server_variables = server_variables or {}
227
+ self.server_operation_variables = server_operation_variables or {}
228
+ """Default server variables
229
+ """
230
+ self.ignore_operation_servers = ignore_operation_servers
231
+ """Ignore operation servers
232
+ """
233
+ self.temp_folder_path = None
234
+ """Temp file folder for downloading files
235
+ """
236
+ # Authentication Settings
237
+ self.api_key = {}
238
+ if api_key:
239
+ self.api_key = api_key
240
+ """dict to store API key(s)
241
+ """
242
+ self.api_key_prefix = {}
243
+ if api_key_prefix:
244
+ self.api_key_prefix = api_key_prefix
245
+ """dict to store API prefix (e.g. Bearer)
246
+ """
247
+ self.refresh_api_key_hook = None
248
+ """function hook to refresh API key if expired
249
+ """
250
+ self.username = username
251
+ """Username for HTTP basic authentication
252
+ """
253
+ self.password = password
254
+ """Password for HTTP basic authentication
255
+ """
256
+ self.access_token = access_token
257
+ """Access token
258
+ """
259
+ self.logger = {}
260
+ """Logging Settings
261
+ """
262
+ self.logger["package_logger"] = logging.getLogger("elastly")
263
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
264
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
265
+ """Log format
266
+ """
267
+ self.logger_stream_handler = None
268
+ """Log stream handler
269
+ """
270
+ self.logger_file_handler: Optional[FileHandler] = None
271
+ """Log file handler
272
+ """
273
+ self.logger_file = None
274
+ """Debug file location
275
+ """
276
+ if debug is not None:
277
+ self.debug = debug
278
+ else:
279
+ self.__debug = False
280
+ """Debug switch
281
+ """
282
+
283
+ self.verify_ssl = verify_ssl
284
+ """SSL/TLS verification
285
+ Set this to false to skip verifying SSL certificate when calling API
286
+ from https server.
287
+ """
288
+ self.ssl_ca_cert = ssl_ca_cert
289
+ """Set this to customize the certificate file to verify the peer.
290
+ """
291
+ self.ca_cert_data = ca_cert_data
292
+ """Set this to verify the peer using PEM (str) or DER (bytes)
293
+ certificate data.
294
+ """
295
+ self.cert_file = cert_file
296
+ """client certificate file
297
+ """
298
+ self.key_file = key_file
299
+ """client key file
300
+ """
301
+ self.assert_hostname = assert_hostname
302
+ """Set this to True/False to enable/disable SSL hostname verification.
303
+ """
304
+ self.tls_server_name = tls_server_name
305
+ """SSL/TLS Server Name Indication (SNI)
306
+ Set this to the SNI value expected by the server.
307
+ """
308
+
309
+ self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else multiprocessing.cpu_count() * 5
310
+ """urllib3 connection pool's maximum number of connections saved
311
+ per pool. None in the constructor is coerced to cpu_count * 5.
312
+ """
313
+
314
+ self.proxy = proxy
315
+ """Proxy URL
316
+ """
317
+ self.proxy_headers = proxy_headers
318
+ """Proxy headers
319
+ """
320
+ self.safe_chars_for_path_param = safe_chars_for_path_param
321
+ """Safe chars for path_param
322
+ """
323
+ self.retries = retries
324
+ """Retry configuration
325
+ """
326
+ # Enable client side validation
327
+ self.client_side_validation = client_side_validation
328
+
329
+ self.socket_options = socket_options
330
+ """Options to pass down to the underlying urllib3 socket
331
+ """
332
+
333
+ self.datetime_format = datetime_format
334
+ """datetime format
335
+ """
336
+
337
+ self.date_format = date_format
338
+ """date format
339
+ """
340
+
341
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
342
+ cls = self.__class__
343
+ result = cls.__new__(cls)
344
+ memo[id(self)] = result
345
+ for k, v in self.__dict__.items():
346
+ if k not in ('logger', 'logger_file_handler'):
347
+ setattr(result, k, copy.deepcopy(v, memo))
348
+ # shallow copy of loggers
349
+ result.logger = copy.copy(self.logger)
350
+ # use setters to configure loggers
351
+ result.logger_file = self.logger_file
352
+ result.debug = self.debug
353
+ return result
354
+
355
+ def __setattr__(self, name: str, value: Any) -> None:
356
+ object.__setattr__(self, name, value)
357
+
358
+ @classmethod
359
+ def set_default(cls, default: Optional[Self]) -> None:
360
+ """Set default instance of configuration.
361
+
362
+ It stores default configuration, which can be
363
+ returned by get_default_copy method.
364
+
365
+ :param default: object of Configuration
366
+ """
367
+ cls._default = default
368
+
369
+ @classmethod
370
+ def get_default_copy(cls) -> Self:
371
+ """Deprecated. Please use `get_default` instead.
372
+
373
+ Deprecated. Please use `get_default` instead.
374
+
375
+ :return: The configuration object.
376
+ """
377
+ return cls.get_default()
378
+
379
+ @classmethod
380
+ def get_default(cls) -> Self:
381
+ """Return the default configuration.
382
+
383
+ This method returns newly created, based on default constructor,
384
+ object of Configuration class or returns a copy of default
385
+ configuration.
386
+
387
+ :return: The configuration object.
388
+ """
389
+ if cls._default is None:
390
+ cls._default = cls()
391
+ return cls._default
392
+
393
+ @property
394
+ def logger_file(self) -> Optional[str]:
395
+ """The logger file.
396
+
397
+ If the logger_file is None, then add stream handler and remove file
398
+ handler. Otherwise, add file handler and remove stream handler.
399
+
400
+ :param value: The logger_file path.
401
+ :type: str
402
+ """
403
+ return self.__logger_file
404
+
405
+ @logger_file.setter
406
+ def logger_file(self, value: Optional[str]) -> None:
407
+ """The logger file.
408
+
409
+ If the logger_file is None, then add stream handler and remove file
410
+ handler. Otherwise, add file handler and remove stream handler.
411
+
412
+ :param value: The logger_file path.
413
+ :type: str
414
+ """
415
+ self.__logger_file = value
416
+ if self.__logger_file:
417
+ # If set logging file,
418
+ # then add file handler and remove stream handler.
419
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
420
+ self.logger_file_handler.setFormatter(self.logger_formatter)
421
+ for _, logger in self.logger.items():
422
+ logger.addHandler(self.logger_file_handler)
423
+
424
+ @property
425
+ def debug(self) -> bool:
426
+ """Debug status
427
+
428
+ :param value: The debug status, True or False.
429
+ :type: bool
430
+ """
431
+ return self.__debug
432
+
433
+ @debug.setter
434
+ def debug(self, value: bool) -> None:
435
+ """Debug status
436
+
437
+ :param value: The debug status, True or False.
438
+ :type: bool
439
+ """
440
+ self.__debug = value
441
+ if self.__debug:
442
+ # if debug status is True, turn on debug logging
443
+ for _, logger in self.logger.items():
444
+ logger.setLevel(logging.DEBUG)
445
+ # turn on httplib debug
446
+ httplib.HTTPConnection.debuglevel = 1
447
+ else:
448
+ # if debug status is False, turn off debug logging,
449
+ # setting log level to default `logging.WARNING`
450
+ for _, logger in self.logger.items():
451
+ logger.setLevel(logging.WARNING)
452
+ # turn off httplib debug
453
+ httplib.HTTPConnection.debuglevel = 0
454
+
455
+ @property
456
+ def logger_format(self) -> str:
457
+ """The logger format.
458
+
459
+ The logger_formatter will be updated when sets logger_format.
460
+
461
+ :param value: The format string.
462
+ :type: str
463
+ """
464
+ return self.__logger_format
465
+
466
+ @logger_format.setter
467
+ def logger_format(self, value: str) -> None:
468
+ """The logger format.
469
+
470
+ The logger_formatter will be updated when sets logger_format.
471
+
472
+ :param value: The format string.
473
+ :type: str
474
+ """
475
+ self.__logger_format = value
476
+ self.logger_formatter = logging.Formatter(self.__logger_format)
477
+
478
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
479
+ """Gets API key (with prefix if set).
480
+
481
+ :param identifier: The identifier of apiKey.
482
+ :param alias: The alternative identifier of apiKey.
483
+ :return: The token for api key authentication.
484
+ """
485
+ if self.refresh_api_key_hook is not None:
486
+ self.refresh_api_key_hook(self)
487
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
488
+ if key:
489
+ prefix = self.api_key_prefix.get(identifier)
490
+ if prefix:
491
+ return "%s %s" % (prefix, key)
492
+ else:
493
+ return key
494
+
495
+ return None
496
+
497
+ def get_basic_auth_token(self) -> Optional[str]:
498
+ """Gets HTTP basic authentication header (string).
499
+
500
+ :return: The token for basic HTTP authentication.
501
+ """
502
+ username = ""
503
+ if self.username is not None:
504
+ username = self.username
505
+ password = ""
506
+ if self.password is not None:
507
+ password = self.password
508
+
509
+ return urllib3.util.make_headers(
510
+ basic_auth=username + ':' + password
511
+ ).get('authorization')
512
+
513
+ def auth_settings(self)-> AuthSettings:
514
+ """Gets Auth Settings dict for api client.
515
+
516
+ :return: The Auth Settings information dict.
517
+ """
518
+ auth: AuthSettings = {}
519
+ if self.access_token is not None:
520
+ auth['apiKey'] = {
521
+ 'type': 'bearer',
522
+ 'in': 'header',
523
+ 'key': 'Authorization',
524
+ 'value': 'Bearer ' + self.access_token
525
+ }
526
+ return auth
527
+
528
+ def to_debug_report(self) -> str:
529
+ """Gets the essential information for debugging.
530
+
531
+ :return: The report for debugging.
532
+ """
533
+ return "Python SDK Debug Report:\n"\
534
+ "OS: {env}\n"\
535
+ "Python Version: {pyversion}\n"\
536
+ "Version of the API: 1.0.0\n"\
537
+ "SDK Package Version: 0.1.0".\
538
+ format(env=sys.platform, pyversion=sys.version)
539
+
540
+ def get_host_settings(self) -> List[HostSetting]:
541
+ """Gets an array of host settings
542
+
543
+ :return: An array of host settings
544
+ """
545
+ return [
546
+ {
547
+ 'url': "https://app.elastly.io",
548
+ 'description': "No description provided",
549
+ }
550
+ ]
551
+
552
+ def get_host_from_settings(
553
+ self,
554
+ index: Optional[int],
555
+ variables: Optional[ServerVariablesT]=None,
556
+ servers: Optional[List[HostSetting]]=None,
557
+ ) -> str:
558
+ """Gets host URL based on the index and variables
559
+ :param index: array index of the host settings
560
+ :param variables: hash of variable and the corresponding value
561
+ :param servers: an array of host settings or None
562
+ :return: URL based on host settings
563
+ """
564
+ if index is None:
565
+ return self._base_path
566
+
567
+ variables = {} if variables is None else variables
568
+ servers = self.get_host_settings() if servers is None else servers
569
+
570
+ try:
571
+ server = servers[index]
572
+ except IndexError:
573
+ raise ValueError(
574
+ "Invalid index {0} when selecting the host settings. "
575
+ "Must be less than {1}".format(index, len(servers)))
576
+
577
+ url = server['url']
578
+
579
+ # go through variables and replace placeholders
580
+ for variable_name, variable in server.get('variables', {}).items():
581
+ used_value = variables.get(
582
+ variable_name, variable['default_value'])
583
+
584
+ if 'enum_values' in variable \
585
+ and variable['enum_values'] \
586
+ and used_value not in variable['enum_values']:
587
+ raise ValueError(
588
+ "The variable `{0}` in the host URL has invalid value "
589
+ "{1}. Must be {2}.".format(
590
+ variable_name, variables[variable_name],
591
+ variable['enum_values']))
592
+
593
+ url = url.replace("{" + variable_name + "}", used_value)
594
+
595
+ return url
596
+
597
+ @property
598
+ def host(self) -> str:
599
+ """Return generated host."""
600
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
601
+
602
+ @host.setter
603
+ def host(self, value: str) -> None:
604
+ """Fix base path."""
605
+ self._base_path = value
606
+ self.server_index = None