|
1 | 1 | """This module contains the Client interface.""" |
2 | 2 | from __future__ import annotations |
3 | 3 |
|
4 | | -from abc import abstractmethod |
5 | | -from typing import Dict, List, Optional, Union |
| 4 | +from typing import Any, Dict, List, Optional, Protocol, Union |
6 | 5 |
|
7 | | -from polywrap_manifest import AnyWrapManifest |
| 6 | +from polywrap_manifest import AnyWrapManifest, DeserializeManifestOptions |
8 | 7 |
|
9 | | -from .env import Env |
10 | 8 | from .invoker_client import InvokerClient |
11 | | -from .options.file_options import GetFileOptions |
12 | | -from .options.manifest_options import GetManifestOptions |
13 | 9 | from .uri import Uri |
14 | | -from .uri_package_wrapper import UriPackageOrWrapper |
15 | 10 | from .uri_resolver import UriResolver |
16 | 11 |
|
17 | 12 |
|
18 | | -class Client(InvokerClient[UriPackageOrWrapper]): |
| 13 | +class Client(InvokerClient, Protocol): |
19 | 14 | """Client interface defines core set of functionalities\ |
20 | 15 | for interacting with a wrapper.""" |
21 | 16 |
|
22 | | - @abstractmethod |
23 | 17 | def get_interfaces(self) -> Dict[Uri, List[Uri]]: |
24 | 18 | """Get dictionary of interfaces and their implementations. |
25 | 19 |
|
26 | 20 | Returns: |
27 | 21 | Dict[Uri, List[Uri]]: Dictionary of interfaces and their implementations where\ |
28 | 22 | key is interface URI and value is list of implementation uris. |
29 | 23 | """ |
| 24 | + ... |
30 | 25 |
|
31 | | - @abstractmethod |
32 | | - def get_envs(self) -> Dict[Uri, Env]: |
| 26 | + def get_envs(self) -> Dict[Uri, Any]: |
33 | 27 | """Get dictionary of environments. |
34 | 28 |
|
35 | 29 | Returns: |
36 | | - Dict[Uri, Env]: Dictionary of environments where key is URI and value is env. |
| 30 | + Dict[Uri, Any]: Dictionary of environments where key is URI and value is env. |
37 | 31 | """ |
| 32 | + ... |
38 | 33 |
|
39 | | - @abstractmethod |
40 | | - def get_env_by_uri(self, uri: Uri) -> Union[Env, None]: |
| 34 | + def get_env_by_uri(self, uri: Uri) -> Union[Any, None]: |
41 | 35 | """Get environment by URI. |
42 | 36 |
|
43 | 37 | Args: |
44 | 38 | uri (Uri): URI of the Wrapper. |
45 | 39 |
|
46 | 40 | Returns: |
47 | | - Union[Env, None]: env if found, otherwise None. |
| 41 | + Union[Any, None]: env if found, otherwise None. |
48 | 42 | """ |
| 43 | + ... |
49 | 44 |
|
50 | | - @abstractmethod |
51 | 45 | def get_uri_resolver(self) -> UriResolver: |
52 | 46 | """Get URI resolver. |
53 | 47 |
|
54 | 48 | Returns: |
55 | | - IUriResolver: URI resolver. |
| 49 | + UriResolver: URI resolver. |
56 | 50 | """ |
| 51 | + ... |
57 | 52 |
|
58 | | - @abstractmethod |
59 | | - async def get_file(self, uri: Uri, options: GetFileOptions) -> Union[bytes, str]: |
| 53 | + def get_file( |
| 54 | + self, uri: Uri, path: str, encoding: Optional[str] = "utf-8" |
| 55 | + ) -> Union[bytes, str]: |
60 | 56 | """Get file from URI. |
61 | 57 |
|
62 | 58 | Args: |
63 | 59 | uri (Uri): URI of the wrapper. |
64 | | - options (GetFileOptions): Options for getting file from the wrapper. |
| 60 | + path (str): Path to the file. |
| 61 | + encoding (Optional[str]): Encoding of the file. |
65 | 62 |
|
66 | 63 | Returns: |
67 | 64 | Union[bytes, str]]: file contents. |
68 | 65 | """ |
| 66 | + ... |
69 | 67 |
|
70 | | - @abstractmethod |
71 | | - async def get_manifest( |
72 | | - self, uri: Uri, options: Optional[GetManifestOptions] = None |
| 68 | + def get_manifest( |
| 69 | + self, uri: Uri, options: Optional[DeserializeManifestOptions] = None |
73 | 70 | ) -> AnyWrapManifest: |
74 | 71 | """Get manifest from URI. |
75 | 72 |
|
76 | 73 | Args: |
77 | 74 | uri (Uri): URI of the wrapper. |
78 | | - options (Optional[GetManifestOptions]): \ |
| 75 | + options (Optional[DeserializeManifestOptions]): \ |
79 | 76 | Options for getting manifest from the wrapper. |
80 | 77 |
|
81 | 78 | Returns: |
82 | 79 | AnyWrapManifest: Manifest of the wrapper. |
83 | 80 | """ |
| 81 | + ... |
| 82 | + |
| 83 | + |
| 84 | +__all__ = ["Client"] |
0 commit comments