|
| 1 | +# Code generated generate_clients.go. DO NOT EDIT. |
| 2 | + |
| 3 | +from contextlib import contextmanager |
| 4 | +from connecpy.context import ClientContext |
| 5 | +from connecpy.exceptions import ConnecpyServerException |
| 6 | + |
| 7 | +from metalstack.admin.v2 import filesystem_pb2 as admin_filesystem_pb2 |
| 8 | +from metalstack.admin.v2 import filesystem_connecpy as admin_filesystem_connecpy |
| 9 | +from metalstack.admin.v2 import image_pb2 as admin_image_pb2 |
| 10 | +from metalstack.admin.v2 import image_connecpy as admin_image_connecpy |
| 11 | +from metalstack.admin.v2 import ip_pb2 as admin_ip_pb2 |
| 12 | +from metalstack.admin.v2 import ip_connecpy as admin_ip_connecpy |
| 13 | +from metalstack.admin.v2 import network_pb2 as admin_network_pb2 |
| 14 | +from metalstack.admin.v2 import network_connecpy as admin_network_connecpy |
| 15 | +from metalstack.admin.v2 import partition_pb2 as admin_partition_pb2 |
| 16 | +from metalstack.admin.v2 import partition_connecpy as admin_partition_connecpy |
| 17 | +from metalstack.admin.v2 import size_pb2 as admin_size_pb2 |
| 18 | +from metalstack.admin.v2 import size_connecpy as admin_size_connecpy |
| 19 | +from metalstack.admin.v2 import tenant_pb2 as admin_tenant_pb2 |
| 20 | +from metalstack.admin.v2 import tenant_connecpy as admin_tenant_connecpy |
| 21 | +from metalstack.admin.v2 import token_pb2 as admin_token_pb2 |
| 22 | +from metalstack.admin.v2 import token_connecpy as admin_token_connecpy |
| 23 | + |
| 24 | +from metalstack.api.v2 import filesystem_pb2 as api_filesystem_pb2 |
| 25 | +from metalstack.api.v2 import filesystem_connecpy as api_filesystem_connecpy |
| 26 | +from metalstack.api.v2 import health_pb2 as api_health_pb2 |
| 27 | +from metalstack.api.v2 import health_connecpy as api_health_connecpy |
| 28 | +from metalstack.api.v2 import image_pb2 as api_image_pb2 |
| 29 | +from metalstack.api.v2 import image_connecpy as api_image_connecpy |
| 30 | +from metalstack.api.v2 import ip_pb2 as api_ip_pb2 |
| 31 | +from metalstack.api.v2 import ip_connecpy as api_ip_connecpy |
| 32 | +from metalstack.api.v2 import method_pb2 as api_method_pb2 |
| 33 | +from metalstack.api.v2 import method_connecpy as api_method_connecpy |
| 34 | +from metalstack.api.v2 import network_pb2 as api_network_pb2 |
| 35 | +from metalstack.api.v2 import network_connecpy as api_network_connecpy |
| 36 | +from metalstack.api.v2 import partition_pb2 as api_partition_pb2 |
| 37 | +from metalstack.api.v2 import partition_connecpy as api_partition_connecpy |
| 38 | +from metalstack.api.v2 import project_pb2 as api_project_pb2 |
| 39 | +from metalstack.api.v2 import project_connecpy as api_project_connecpy |
| 40 | +from metalstack.api.v2 import size_pb2 as api_size_pb2 |
| 41 | +from metalstack.api.v2 import size_connecpy as api_size_connecpy |
| 42 | +from metalstack.api.v2 import tenant_pb2 as api_tenant_pb2 |
| 43 | +from metalstack.api.v2 import tenant_connecpy as api_tenant_connecpy |
| 44 | +from metalstack.api.v2 import token_pb2 as api_token_pb2 |
| 45 | +from metalstack.api.v2 import token_connecpy as api_token_connecpy |
| 46 | +from metalstack.api.v2 import user_pb2 as api_user_pb2 |
| 47 | +from metalstack.api.v2 import user_connecpy as api_user_connecpy |
| 48 | +from metalstack.api.v2 import version_pb2 as api_version_pb2 |
| 49 | +from metalstack.api.v2 import version_connecpy as api_version_connecpy |
| 50 | + |
| 51 | +from metalstack.infra.v2 import bmc_pb2 as infra_bmc_pb2 |
| 52 | +from metalstack.infra.v2 import bmc_connecpy as infra_bmc_connecpy |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +class ClientWrapper: |
| 57 | + def __init__(self, client, token): |
| 58 | + self._client = client |
| 59 | + self._token = token |
| 60 | + |
| 61 | + def __getattr__(self, name): |
| 62 | + attr = getattr(self._client, name) |
| 63 | + if callable(attr): |
| 64 | + def wrapper(*args, **kwargs): |
| 65 | + kwargs.setdefault("ctx", ClientContext()) |
| 66 | + headers = kwargs.get("headers", {}) |
| 67 | + headers.setdefault("Authorization", "Bearer " + self._token) |
| 68 | + kwargs["headers"] = headers |
| 69 | + return attr(*args, **kwargs) |
| 70 | + return wrapper |
| 71 | + return attr |
| 72 | + |
| 73 | +class AdminDriver: |
| 74 | + def __init__(self, baseurl: str, token: str, timeout: int = 10): |
| 75 | + self.baseurl = baseurl |
| 76 | + self.token = token |
| 77 | + self.timeout = timeout |
| 78 | + |
| 79 | + |
| 80 | + @contextmanager |
| 81 | + def filesystem(self): |
| 82 | + with admin_filesystem_connecpy.FilesystemServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 83 | + yield ClientWrapper(client, self.token) |
| 84 | + |
| 85 | + |
| 86 | + @contextmanager |
| 87 | + def image(self): |
| 88 | + with admin_image_connecpy.ImageServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 89 | + yield ClientWrapper(client, self.token) |
| 90 | + |
| 91 | + |
| 92 | + @contextmanager |
| 93 | + def ip(self): |
| 94 | + with admin_ip_connecpy.IPServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 95 | + yield ClientWrapper(client, self.token) |
| 96 | + |
| 97 | + |
| 98 | + @contextmanager |
| 99 | + def network(self): |
| 100 | + with admin_network_connecpy.NetworkServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 101 | + yield ClientWrapper(client, self.token) |
| 102 | + |
| 103 | + |
| 104 | + @contextmanager |
| 105 | + def partition(self): |
| 106 | + with admin_partition_connecpy.PartitionServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 107 | + yield ClientWrapper(client, self.token) |
| 108 | + |
| 109 | + |
| 110 | + @contextmanager |
| 111 | + def size(self): |
| 112 | + with admin_size_connecpy.SizeServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 113 | + yield ClientWrapper(client, self.token) |
| 114 | + |
| 115 | + |
| 116 | + @contextmanager |
| 117 | + def tenant(self): |
| 118 | + with admin_tenant_connecpy.TenantServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 119 | + yield ClientWrapper(client, self.token) |
| 120 | + |
| 121 | + |
| 122 | + @contextmanager |
| 123 | + def token(self): |
| 124 | + with admin_token_connecpy.TokenServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 125 | + yield ClientWrapper(client, self.token) |
| 126 | + |
| 127 | + |
| 128 | +class ApiDriver: |
| 129 | + def __init__(self, baseurl: str, token: str, timeout: int = 10): |
| 130 | + self.baseurl = baseurl |
| 131 | + self.token = token |
| 132 | + self.timeout = timeout |
| 133 | + |
| 134 | + |
| 135 | + @contextmanager |
| 136 | + def filesystem(self): |
| 137 | + with api_filesystem_connecpy.FilesystemServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 138 | + yield ClientWrapper(client, self.token) |
| 139 | + |
| 140 | + |
| 141 | + @contextmanager |
| 142 | + def health(self): |
| 143 | + with api_health_connecpy.HealthServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 144 | + yield ClientWrapper(client, self.token) |
| 145 | + |
| 146 | + |
| 147 | + @contextmanager |
| 148 | + def image(self): |
| 149 | + with api_image_connecpy.ImageServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 150 | + yield ClientWrapper(client, self.token) |
| 151 | + |
| 152 | + |
| 153 | + @contextmanager |
| 154 | + def ip(self): |
| 155 | + with api_ip_connecpy.IPServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 156 | + yield ClientWrapper(client, self.token) |
| 157 | + |
| 158 | + |
| 159 | + @contextmanager |
| 160 | + def method(self): |
| 161 | + with api_method_connecpy.MethodServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 162 | + yield ClientWrapper(client, self.token) |
| 163 | + |
| 164 | + |
| 165 | + @contextmanager |
| 166 | + def network(self): |
| 167 | + with api_network_connecpy.NetworkServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 168 | + yield ClientWrapper(client, self.token) |
| 169 | + |
| 170 | + |
| 171 | + @contextmanager |
| 172 | + def partition(self): |
| 173 | + with api_partition_connecpy.PartitionServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 174 | + yield ClientWrapper(client, self.token) |
| 175 | + |
| 176 | + |
| 177 | + @contextmanager |
| 178 | + def project(self): |
| 179 | + with api_project_connecpy.ProjectServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 180 | + yield ClientWrapper(client, self.token) |
| 181 | + |
| 182 | + |
| 183 | + @contextmanager |
| 184 | + def size(self): |
| 185 | + with api_size_connecpy.SizeServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 186 | + yield ClientWrapper(client, self.token) |
| 187 | + |
| 188 | + |
| 189 | + @contextmanager |
| 190 | + def tenant(self): |
| 191 | + with api_tenant_connecpy.TenantServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 192 | + yield ClientWrapper(client, self.token) |
| 193 | + |
| 194 | + |
| 195 | + @contextmanager |
| 196 | + def token(self): |
| 197 | + with api_token_connecpy.TokenServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 198 | + yield ClientWrapper(client, self.token) |
| 199 | + |
| 200 | + |
| 201 | + @contextmanager |
| 202 | + def user(self): |
| 203 | + with api_user_connecpy.UserServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 204 | + yield ClientWrapper(client, self.token) |
| 205 | + |
| 206 | + |
| 207 | + @contextmanager |
| 208 | + def version(self): |
| 209 | + with api_version_connecpy.VersionServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 210 | + yield ClientWrapper(client, self.token) |
| 211 | + |
| 212 | + |
| 213 | +class InfraDriver: |
| 214 | + def __init__(self, baseurl: str, token: str, timeout: int = 10): |
| 215 | + self.baseurl = baseurl |
| 216 | + self.token = token |
| 217 | + self.timeout = timeout |
| 218 | + |
| 219 | + |
| 220 | + @contextmanager |
| 221 | + def bmc(self): |
| 222 | + with infra_bmc_connecpy.BMCServiceClient(self.baseurl, timeout=self.timeout) as client: |
| 223 | + yield ClientWrapper(client, self.token) |
| 224 | + |
| 225 | + |
| 226 | + |
0 commit comments