|
| 1 | +# Licensed to the Software Freedom Conservancy (SFC) 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 SFC 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 | + |
| 18 | +from selenium.webdriver.common.proxy import Proxy |
| 19 | +from selenium.webdriver.common.proxy import ProxyType |
| 20 | + |
| 21 | + |
| 22 | +class ClientConfig: |
| 23 | + |
| 24 | + def __init__( |
| 25 | + self, keep_alive: bool = True, timeout=None, proxy=Proxy({"proxyType": ProxyType.SYSTEM}), certificate_path=None |
| 26 | + ) -> None: |
| 27 | + self._keep_alive = keep_alive |
| 28 | + self._timeout = timeout |
| 29 | + self._proxy = proxy |
| 30 | + self._certificate_path = certificate_path |
| 31 | + |
| 32 | + @property |
| 33 | + def keep_alive(self) -> bool: |
| 34 | + """:Returns: The keep alive value""" |
| 35 | + return self._keep_alive |
| 36 | + |
| 37 | + @keep_alive.setter |
| 38 | + def keep_alive(self, value: bool) -> None: |
| 39 | + """Toggles the keep alive value. |
| 40 | +
|
| 41 | + :Args: |
| 42 | + - value: whether to keep the http connection alive |
| 43 | + """ |
| 44 | + self._keep_alive = value |
| 45 | + |
| 46 | + @property |
| 47 | + def timeout(self) -> int: |
| 48 | + """:Returns: The amount of time to wait for an http response.""" |
| 49 | + return self._timeout |
| 50 | + |
| 51 | + @timeout.setter |
| 52 | + def timeout(self, time: int) -> None: |
| 53 | + """Sets the amount of time to wait for an http response. |
| 54 | +
|
| 55 | + :Args: |
| 56 | + - value: number of seconds to wait for an http response |
| 57 | + """ |
| 58 | + self._timeout = time |
| 59 | + |
| 60 | + @property |
| 61 | + def proxy(self) -> Proxy: |
| 62 | + """:Returns: The proxy used for communicating to the driver/server""" |
| 63 | + return self._proxy |
| 64 | + |
| 65 | + @proxy.setter |
| 66 | + def proxy(self, proxy: Proxy) -> None: |
| 67 | + """Provides the information for communicating with the driver or server. |
| 68 | +
|
| 69 | + :Args: |
| 70 | + - value: the proxy information to use to communicate with the driver or server |
| 71 | + """ |
| 72 | + self._proxy = proxy |
| 73 | + |
| 74 | + @property |
| 75 | + def certificate_path(self) -> bool: |
| 76 | + """:Returns: The path of the .pem encoded certificate |
| 77 | + used to verify connection to the driver or server |
| 78 | + """ |
| 79 | + return self._certificate_path |
| 80 | + |
| 81 | + @certificate_path.setter |
| 82 | + def certificate_path(self, path: str) -> None: |
| 83 | + """Set the path to the certificate bundle to verify connection to |
| 84 | + command executor. Can also be set to None to disable certificate |
| 85 | + validation. |
| 86 | +
|
| 87 | + :Args: |
| 88 | + - path - path of a .pem encoded certificate chain. |
| 89 | + """ |
| 90 | + self._certificate_path = path |
0 commit comments