How to use _serialize method in localstack

Best Python code snippet using localstack_python

training.py

Source:training.py Github

copy

Full Screen

1# coding=utf-82# --------------------------------------------------------------------------3# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.04# Changes may cause incorrect behavior and will be lost if the code is5# regenerated.6# --------------------------------------------------------------------------7from msrest.service_client import ServiceClient8from msrest import Configuration, Serializer, Deserializer9from .version import VERSION10from msrest.pipeline import ClientRawResponse11from msrest.exceptions import HttpOperationError12from . import models13class TrainingConfiguration(Configuration):14 """Configuration for Training15 Note that all parameters used to create this instance are saved as instance16 attributes.17 :param str base_url: Service URL18 """19 def __init__(20 self, base_url=None):21 if not base_url:22 base_url = 'https://customvisionppe.azure-api.net/v1.0/Training'23 super(TrainingConfiguration, self).__init__(base_url)24 self.add_user_agent('training/{}'.format(VERSION))25class Training(object):26 """Training27 :ivar config: Configuration for client.28 :vartype config: TrainingConfiguration29 :param str base_url: Service URL30 """31 def __init__(32 self, base_url=None):33 self.config = TrainingConfiguration(base_url)34 self._client = ServiceClient(None, self.config)35 client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}36 self.api_version = '1.0'37 self._serialize = Serializer(client_models)38 self._deserialize = Deserializer(client_models)39 def get_projects(40 self, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):41 """Gets the user's projects.42 :param training_key: subscription key in url43 :type training_key: str44 :param training_key1: subscription key in header45 :type training_key1: str46 :param dict custom_headers: headers that will be added to the request47 :param bool raw: returns the direct response alongside the48 deserialized response49 :param operation_config: :ref:`Operation configuration50 overrides<msrest:optionsforoperations>`.51 :rtype: list of :class:`ProjectModel <training.models.ProjectModel>`52 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`53 if raw=true54 :raises:55 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`56 """57 # Construct URL58 url = '/'59 # Construct parameters60 query_parameters = {}61 if training_key is not None:62 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')63 # Construct headers64 header_parameters = {}65 header_parameters['Content-Type'] = 'application/json; charset=utf-8'66 if custom_headers:67 header_parameters.update(custom_headers)68 if training_key1 is not None:69 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')70 # Construct and send request71 request = self._client.get(url, query_parameters)72 response = self._client.send(request, header_parameters, **operation_config)73 if response.status_code not in [200]:74 raise HttpOperationError(self._deserialize, response)75 deserialized = None76 if response.status_code == 200:77 deserialized = self._deserialize('[ProjectModel]', response)78 if raw:79 client_raw_response = ClientRawResponse(deserialized, response)80 return client_raw_response81 return deserialized82 def create_project(83 self, training_key=None, training_key1=None, project_update_model=None, custom_headers=None, raw=False, **operation_config):84 """Create a project.85 :param training_key: subscription key in url86 :type training_key: str87 :param training_key1: subscription key in header88 :type training_key1: str89 :param project_update_model: information about the project to be90 created91 :type project_update_model: :class:`ProjectUpdateModel92 <training.models.ProjectUpdateModel>`93 :param dict custom_headers: headers that will be added to the request94 :param bool raw: returns the direct response alongside the95 deserialized response96 :param operation_config: :ref:`Operation configuration97 overrides<msrest:optionsforoperations>`.98 :rtype: :class:`ProjectModel <training.models.ProjectModel>`99 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`100 if raw=true101 :raises:102 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`103 """104 # Construct URL105 url = '/'106 # Construct parameters107 query_parameters = {}108 if training_key is not None:109 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')110 # Construct headers111 header_parameters = {}112 header_parameters['Content-Type'] = 'application/json; charset=utf-8'113 if custom_headers:114 header_parameters.update(custom_headers)115 if training_key1 is not None:116 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')117 # Construct body118 if project_update_model is not None:119 body_content = self._serialize.body(project_update_model, 'ProjectUpdateModel')120 else:121 body_content = None122 # Construct and send request123 request = self._client.post(url, query_parameters)124 response = self._client.send(125 request, header_parameters, body_content, **operation_config)126 if response.status_code not in [200]:127 raise HttpOperationError(self._deserialize, response)128 deserialized = None129 if response.status_code == 200:130 deserialized = self._deserialize('ProjectModel', response)131 if raw:132 client_raw_response = ClientRawResponse(deserialized, response)133 return client_raw_response134 return deserialized135 def delete_project(136 self, project_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):137 """Delete a specific project.138 :param project_id: Format - uuid. Guid of the projectId139 :type project_id: str140 :param training_key: subscription key in url141 :type training_key: str142 :param training_key1: subscription key in header143 :type training_key1: str144 :param dict custom_headers: headers that will be added to the request145 :param bool raw: returns the direct response alongside the146 deserialized response147 :param operation_config: :ref:`Operation configuration148 overrides<msrest:optionsforoperations>`.149 :rtype: None150 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`151 if raw=true152 :raises:153 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`154 """155 # Construct URL156 url = '/{projectId}'157 path_format_arguments = {158 'projectId': self._serialize.url("project_id", project_id, 'str')159 }160 url = self._client.format_url(url, **path_format_arguments)161 # Construct parameters162 query_parameters = {}163 if training_key is not None:164 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')165 # Construct headers166 header_parameters = {}167 header_parameters['Content-Type'] = 'application/json; charset=utf-8'168 if custom_headers:169 header_parameters.update(custom_headers)170 if training_key1 is not None:171 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')172 # Construct and send request173 request = self._client.delete(url, query_parameters)174 response = self._client.send(request, header_parameters, **operation_config)175 if response.status_code not in [204]:176 raise HttpOperationError(self._deserialize, response)177 if raw:178 client_raw_response = ClientRawResponse(None, response)179 return client_raw_response180 def update_project(181 self, project_id, training_key=None, training_key1=None, project_update_model=None, custom_headers=None, raw=False, **operation_config):182 """Update a specific project.183 :param project_id: Format - uuid.184 :type project_id: str185 :param training_key: subscription key in url186 :type training_key: str187 :param training_key1: subscription key in header188 :type training_key1: str189 :param project_update_model:190 :type project_update_model: :class:`ProjectUpdateModel191 <training.models.ProjectUpdateModel>`192 :param dict custom_headers: headers that will be added to the request193 :param bool raw: returns the direct response alongside the194 deserialized response195 :param operation_config: :ref:`Operation configuration196 overrides<msrest:optionsforoperations>`.197 :rtype: :class:`ProjectModel <training.models.ProjectModel>`198 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`199 if raw=true200 :raises:201 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`202 """203 # Construct URL204 url = '/{projectId}'205 path_format_arguments = {206 'projectId': self._serialize.url("project_id", project_id, 'str')207 }208 url = self._client.format_url(url, **path_format_arguments)209 # Construct parameters210 query_parameters = {}211 if training_key is not None:212 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')213 # Construct headers214 header_parameters = {}215 header_parameters['Content-Type'] = 'application/json; charset=utf-8'216 if custom_headers:217 header_parameters.update(custom_headers)218 if training_key1 is not None:219 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')220 # Construct body221 if project_update_model is not None:222 body_content = self._serialize.body(project_update_model, 'ProjectUpdateModel')223 else:224 body_content = None225 # Construct and send request226 request = self._client.patch(url, query_parameters)227 response = self._client.send(228 request, header_parameters, body_content, **operation_config)229 if response.status_code not in [200]:230 raise HttpOperationError(self._deserialize, response)231 deserialized = None232 if response.status_code == 200:233 deserialized = self._deserialize('ProjectModel', response)234 if raw:235 client_raw_response = ClientRawResponse(deserialized, response)236 return client_raw_response237 return deserialized238 def get_classes(239 self, project_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):240 """Get's the project classes.241 :param project_id: Format - uuid.242 :type project_id: str243 :param training_key: subscription key in url244 :type training_key: str245 :param training_key1: subscription key in header246 :type training_key1: str247 :param dict custom_headers: headers that will be added to the request248 :param bool raw: returns the direct response alongside the249 deserialized response250 :param operation_config: :ref:`Operation configuration251 overrides<msrest:optionsforoperations>`.252 :rtype: list of :class:`ImageClassModel253 <training.models.ImageClassModel>`254 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`255 if raw=true256 :raises:257 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`258 """259 # Construct URL260 url = '/{projectId}/classes'261 path_format_arguments = {262 'projectId': self._serialize.url("project_id", project_id, 'str')263 }264 url = self._client.format_url(url, **path_format_arguments)265 # Construct parameters266 query_parameters = {}267 if training_key is not None:268 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')269 # Construct headers270 header_parameters = {}271 header_parameters['Content-Type'] = 'application/json; charset=utf-8'272 if custom_headers:273 header_parameters.update(custom_headers)274 if training_key1 is not None:275 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')276 # Construct and send request277 request = self._client.get(url, query_parameters)278 response = self._client.send(request, header_parameters, **operation_config)279 if response.status_code not in [200]:280 raise HttpOperationError(self._deserialize, response)281 deserialized = None282 if response.status_code == 200:283 deserialized = self._deserialize('[ImageClassModel]', response)284 if raw:285 client_raw_response = ClientRawResponse(deserialized, response)286 return client_raw_response287 return deserialized288 def create_class(289 self, project_id, name, description=None, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):290 """Creates a class for the project.291 :param project_id: Format - uuid.292 :type project_id: str293 :param name:294 :type name: str295 :param description:296 :type description: str297 :param training_key: subscription key in url298 :type training_key: str299 :param training_key1: subscription key in header300 :type training_key1: str301 :param dict custom_headers: headers that will be added to the request302 :param bool raw: returns the direct response alongside the303 deserialized response304 :param operation_config: :ref:`Operation configuration305 overrides<msrest:optionsforoperations>`.306 :rtype: :class:`ImageClassModel <training.models.ImageClassModel>`307 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`308 if raw=true309 :raises:310 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`311 """312 # Construct URL313 url = '/{projectId}/classes'314 path_format_arguments = {315 'projectId': self._serialize.url("project_id", project_id, 'str')316 }317 url = self._client.format_url(url, **path_format_arguments)318 # Construct parameters319 query_parameters = {}320 query_parameters['name'] = self._serialize.query("name", name, 'str')321 if description is not None:322 query_parameters['description'] = self._serialize.query("description", description, 'str')323 if training_key is not None:324 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')325 # Construct headers326 header_parameters = {}327 header_parameters['Content-Type'] = 'application/json; charset=utf-8'328 if custom_headers:329 header_parameters.update(custom_headers)330 if training_key1 is not None:331 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')332 # Construct and send request333 request = self._client.post(url, query_parameters)334 response = self._client.send(request, header_parameters, **operation_config)335 if response.status_code not in [200]:336 raise HttpOperationError(self._deserialize, response)337 deserialized = None338 if response.status_code == 200:339 deserialized = self._deserialize('ImageClassModel', response)340 if raw:341 client_raw_response = ClientRawResponse(deserialized, response)342 return client_raw_response343 return deserialized344 def get_class_images(345 self, project_id, class_id, take=50, skip=0, max_category_rank=1, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):346 """This API supports batching and range selection. By default it will only347 return the first 50 images in a class.348 Use the {take} and {skip} parameters to control how many images to349 return in a given batch.350 If the total number of images in the class is less than ({skip} +351 {take}) the number of images returned will be less than {take}.352 :param project_id: Format - uuid. The id of the project the class is353 part of354 :type project_id: str355 :param class_id: Format - uuid. The id of the class to get images for356 :type class_id: str357 :param take: Format - int32. Maximum number of images to return.358 Defaults to 50359 :type take: int360 :param skip: Format - int32. How many images should be skipped before361 begining the image batch. Defaults to 0362 :type skip: int363 :param max_category_rank: Format - int32. The maximum number of364 categories to return. Defaults to 1365 :type max_category_rank: int366 :param training_key: subscription key in url367 :type training_key: str368 :param training_key1: subscription key in header369 :type training_key1: str370 :param dict custom_headers: headers that will be added to the request371 :param bool raw: returns the direct response alongside the372 deserialized response373 :param operation_config: :ref:`Operation configuration374 overrides<msrest:optionsforoperations>`.375 :rtype: list of :class:`ImageModelObsolete376 <training.models.ImageModelObsolete>`377 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`378 if raw=true379 :raises:380 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`381 """382 # Construct URL383 url = '/{projectId}/classes/{classId}'384 path_format_arguments = {385 'projectId': self._serialize.url("project_id", project_id, 'str'),386 'classId': self._serialize.url("class_id", class_id, 'str')387 }388 url = self._client.format_url(url, **path_format_arguments)389 # Construct parameters390 query_parameters = {}391 if take is not None:392 query_parameters['take'] = self._serialize.query("take", take, 'int')393 if skip is not None:394 query_parameters['skip'] = self._serialize.query("skip", skip, 'int')395 if max_category_rank is not None:396 query_parameters['maxCategoryRank'] = self._serialize.query("max_category_rank", max_category_rank, 'int')397 if training_key is not None:398 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')399 # Construct headers400 header_parameters = {}401 header_parameters['Content-Type'] = 'application/json; charset=utf-8'402 if custom_headers:403 header_parameters.update(custom_headers)404 if training_key1 is not None:405 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')406 # Construct and send request407 request = self._client.get(url, query_parameters)408 response = self._client.send(request, header_parameters, **operation_config)409 if response.status_code not in [200]:410 raise HttpOperationError(self._deserialize, response)411 deserialized = None412 if response.status_code == 200:413 deserialized = self._deserialize('[ImageModelObsolete]', response)414 if raw:415 client_raw_response = ClientRawResponse(deserialized, response)416 return client_raw_response417 return deserialized418 def delete_class(419 self, project_id, class_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):420 """Delete a class for the project.421 :param project_id: Format - uuid.422 :type project_id: str423 :param class_id: Format - uuid.424 :type class_id: str425 :param training_key: subscription key in url426 :type training_key: str427 :param training_key1: subscription key in header428 :type training_key1: str429 :param dict custom_headers: headers that will be added to the request430 :param bool raw: returns the direct response alongside the431 deserialized response432 :param operation_config: :ref:`Operation configuration433 overrides<msrest:optionsforoperations>`.434 :rtype: None435 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`436 if raw=true437 :raises:438 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`439 """440 # Construct URL441 url = '/{projectId}/classes/{classId}'442 path_format_arguments = {443 'projectId': self._serialize.url("project_id", project_id, 'str'),444 'classId': self._serialize.url("class_id", class_id, 'str')445 }446 url = self._client.format_url(url, **path_format_arguments)447 # Construct parameters448 query_parameters = {}449 if training_key is not None:450 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')451 # Construct headers452 header_parameters = {}453 header_parameters['Content-Type'] = 'application/json; charset=utf-8'454 if custom_headers:455 header_parameters.update(custom_headers)456 if training_key1 is not None:457 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')458 # Construct and send request459 request = self._client.delete(url, query_parameters)460 response = self._client.send(request, header_parameters, **operation_config)461 if response.status_code not in [204]:462 raise HttpOperationError(self._deserialize, response)463 if raw:464 client_raw_response = ClientRawResponse(None, response)465 return client_raw_response466 def update_class(467 self, project_id, class_id, name, description=None, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):468 """Updates a class for the project.469 :param project_id: Format - uuid.470 :type project_id: str471 :param class_id: Format - uuid.472 :type class_id: str473 :param name:474 :type name: str475 :param description:476 :type description: str477 :param training_key: subscription key in url478 :type training_key: str479 :param training_key1: subscription key in header480 :type training_key1: str481 :param dict custom_headers: headers that will be added to the request482 :param bool raw: returns the direct response alongside the483 deserialized response484 :param operation_config: :ref:`Operation configuration485 overrides<msrest:optionsforoperations>`.486 :rtype: :class:`ImageClassModel <training.models.ImageClassModel>`487 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`488 if raw=true489 :raises:490 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`491 """492 # Construct URL493 url = '/{projectId}/classes/{classId}'494 path_format_arguments = {495 'projectId': self._serialize.url("project_id", project_id, 'str'),496 'classId': self._serialize.url("class_id", class_id, 'str')497 }498 url = self._client.format_url(url, **path_format_arguments)499 # Construct parameters500 query_parameters = {}501 query_parameters['name'] = self._serialize.query("name", name, 'str')502 if description is not None:503 query_parameters['description'] = self._serialize.query("description", description, 'str')504 if training_key is not None:505 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')506 # Construct headers507 header_parameters = {}508 header_parameters['Content-Type'] = 'application/json; charset=utf-8'509 if custom_headers:510 header_parameters.update(custom_headers)511 if training_key1 is not None:512 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')513 # Construct and send request514 request = self._client.patch(url, query_parameters)515 response = self._client.send(request, header_parameters, **operation_config)516 if response.status_code not in [200]:517 raise HttpOperationError(self._deserialize, response)518 deserialized = None519 if response.status_code == 200:520 deserialized = self._deserialize('ImageClassModel', response)521 if raw:522 client_raw_response = ClientRawResponse(deserialized, response)523 return client_raw_response524 return deserialized525 def train_project(526 self, project_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):527 """Queues training of the current iteration for the project.528 :param project_id: Format - uuid. The project id.529 :type project_id: str530 :param training_key: subscription key in url531 :type training_key: str532 :param training_key1: subscription key in header533 :type training_key1: str534 :param dict custom_headers: headers that will be added to the request535 :param bool raw: returns the direct response alongside the536 deserialized response537 :param operation_config: :ref:`Operation configuration538 overrides<msrest:optionsforoperations>`.539 :rtype: :class:`IterationModel <training.models.IterationModel>`540 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`541 if raw=true542 :raises:543 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`544 """545 # Construct URL546 url = '/{projectId}/train'547 path_format_arguments = {548 'projectId': self._serialize.url("project_id", project_id, 'str')549 }550 url = self._client.format_url(url, **path_format_arguments)551 # Construct parameters552 query_parameters = {}553 if training_key is not None:554 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')555 # Construct headers556 header_parameters = {}557 header_parameters['Content-Type'] = 'application/json; charset=utf-8'558 if custom_headers:559 header_parameters.update(custom_headers)560 if training_key1 is not None:561 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')562 # Construct and send request563 request = self._client.post(url, query_parameters)564 response = self._client.send(request, header_parameters, **operation_config)565 if response.status_code not in [200]:566 raise HttpOperationError(self._deserialize, response)567 deserialized = None568 if response.status_code == 200:569 deserialized = self._deserialize('IterationModel', response)570 if raw:571 client_raw_response = ClientRawResponse(deserialized, response)572 return client_raw_response573 return deserialized574 def get_iterations(575 self, project_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):576 """Get iterations for the project.577 :param project_id: Format - uuid. The project id.578 :type project_id: str579 :param training_key: subscription key in url580 :type training_key: str581 :param training_key1: subscription key in header582 :type training_key1: str583 :param dict custom_headers: headers that will be added to the request584 :param bool raw: returns the direct response alongside the585 deserialized response586 :param operation_config: :ref:`Operation configuration587 overrides<msrest:optionsforoperations>`.588 :rtype: list of :class:`IterationModel589 <training.models.IterationModel>`590 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`591 if raw=true592 :raises:593 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`594 """595 # Construct URL596 url = '/{projectId}/iterations'597 path_format_arguments = {598 'projectId': self._serialize.url("project_id", project_id, 'str')599 }600 url = self._client.format_url(url, **path_format_arguments)601 # Construct parameters602 query_parameters = {}603 if training_key is not None:604 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')605 # Construct headers606 header_parameters = {}607 header_parameters['Content-Type'] = 'application/json; charset=utf-8'608 if custom_headers:609 header_parameters.update(custom_headers)610 if training_key1 is not None:611 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')612 # Construct and send request613 request = self._client.get(url, query_parameters)614 response = self._client.send(request, header_parameters, **operation_config)615 if response.status_code not in [200]:616 raise HttpOperationError(self._deserialize, response)617 deserialized = None618 if response.status_code == 200:619 deserialized = self._deserialize('[IterationModel]', response)620 if raw:621 client_raw_response = ClientRawResponse(deserialized, response)622 return client_raw_response623 return deserialized624 def get_iteration(625 self, project_id, iteration_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):626 """Get a specific iteration.627 :param project_id: Format - uuid. The id of the project the iteration628 belongs to629 :type project_id: str630 :param iteration_id: Format - uuid. The id of the iteration to get631 :type iteration_id: str632 :param training_key: subscription key in url633 :type training_key: str634 :param training_key1: subscription key in header635 :type training_key1: str636 :param dict custom_headers: headers that will be added to the request637 :param bool raw: returns the direct response alongside the638 deserialized response639 :param operation_config: :ref:`Operation configuration640 overrides<msrest:optionsforoperations>`.641 :rtype: :class:`IterationModel <training.models.IterationModel>`642 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`643 if raw=true644 :raises:645 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`646 """647 # Construct URL648 url = '/{projectId}/iterations/{iterationId}'649 path_format_arguments = {650 'projectId': self._serialize.url("project_id", project_id, 'str'),651 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')652 }653 url = self._client.format_url(url, **path_format_arguments)654 # Construct parameters655 query_parameters = {}656 if training_key is not None:657 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')658 # Construct headers659 header_parameters = {}660 header_parameters['Content-Type'] = 'application/json; charset=utf-8'661 if custom_headers:662 header_parameters.update(custom_headers)663 if training_key1 is not None:664 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')665 # Construct and send request666 request = self._client.get(url, query_parameters)667 response = self._client.send(request, header_parameters, **operation_config)668 if response.status_code not in [200]:669 raise HttpOperationError(self._deserialize, response)670 deserialized = None671 if response.status_code == 200:672 deserialized = self._deserialize('IterationModel', response)673 if raw:674 client_raw_response = ClientRawResponse(deserialized, response)675 return client_raw_response676 return deserialized677 def delete_iteration(678 self, project_id, iteration_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):679 """680 :param project_id: Format - uuid.681 :type project_id: str682 :param iteration_id: Format - uuid.683 :type iteration_id: str684 :param training_key: subscription key in url685 :type training_key: str686 :param training_key1: subscription key in header687 :type training_key1: str688 :param dict custom_headers: headers that will be added to the request689 :param bool raw: returns the direct response alongside the690 deserialized response691 :param operation_config: :ref:`Operation configuration692 overrides<msrest:optionsforoperations>`.693 :rtype: None694 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`695 if raw=true696 :raises:697 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`698 """699 # Construct URL700 url = '/{projectId}/iterations/{iterationId}'701 path_format_arguments = {702 'projectId': self._serialize.url("project_id", project_id, 'str'),703 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')704 }705 url = self._client.format_url(url, **path_format_arguments)706 # Construct parameters707 query_parameters = {}708 if training_key is not None:709 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')710 # Construct headers711 header_parameters = {}712 header_parameters['Content-Type'] = 'application/json; charset=utf-8'713 if custom_headers:714 header_parameters.update(custom_headers)715 if training_key1 is not None:716 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')717 # Construct and send request718 request = self._client.delete(url, query_parameters)719 response = self._client.send(request, header_parameters, **operation_config)720 if response.status_code not in [204]:721 raise HttpOperationError(self._deserialize, response)722 if raw:723 client_raw_response = ClientRawResponse(None, response)724 return client_raw_response725 def update_iteration(726 self, project_id, iteration_id, name, note=None, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):727 """728 :param project_id: Format - uuid.729 :type project_id: str730 :param iteration_id: Format - uuid.731 :type iteration_id: str732 :param name:733 :type name: str734 :param note:735 :type note: str736 :param training_key: subscription key in url737 :type training_key: str738 :param training_key1: subscription key in header739 :type training_key1: str740 :param dict custom_headers: headers that will be added to the request741 :param bool raw: returns the direct response alongside the742 deserialized response743 :param operation_config: :ref:`Operation configuration744 overrides<msrest:optionsforoperations>`.745 :rtype: :class:`IterationModel <training.models.IterationModel>`746 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`747 if raw=true748 :raises:749 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`750 """751 # Construct URL752 url = '/{projectId}/iterations/{iterationId}'753 path_format_arguments = {754 'projectId': self._serialize.url("project_id", project_id, 'str'),755 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')756 }757 url = self._client.format_url(url, **path_format_arguments)758 # Construct parameters759 query_parameters = {}760 query_parameters['name'] = self._serialize.query("name", name, 'str')761 if note is not None:762 query_parameters['note'] = self._serialize.query("note", note, 'str')763 if training_key is not None:764 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')765 # Construct headers766 header_parameters = {}767 header_parameters['Content-Type'] = 'application/json; charset=utf-8'768 if custom_headers:769 header_parameters.update(custom_headers)770 if training_key1 is not None:771 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')772 # Construct and send request773 request = self._client.patch(url, query_parameters)774 response = self._client.send(request, header_parameters, **operation_config)775 if response.status_code not in [200]:776 raise HttpOperationError(self._deserialize, response)777 deserialized = None778 if response.status_code == 200:779 deserialized = self._deserialize('IterationModel', response)780 if raw:781 client_raw_response = ClientRawResponse(deserialized, response)782 return client_raw_response783 return deserialized784 def rollback_iteration(785 self, project_id, iteration_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):786 """787 :param project_id: Format - uuid.788 :type project_id: str789 :param iteration_id: Format - uuid.790 :type iteration_id: str791 :param training_key: subscription key in url792 :type training_key: str793 :param training_key1: subscription key in header794 :type training_key1: str795 :param dict custom_headers: headers that will be added to the request796 :param bool raw: returns the direct response alongside the797 deserialized response798 :param operation_config: :ref:`Operation configuration799 overrides<msrest:optionsforoperations>`.800 :rtype: :class:`IterationModel <training.models.IterationModel>`801 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`802 if raw=true803 :raises:804 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`805 """806 # Construct URL807 url = '/{projectId}/iterations/current/{iterationId}'808 path_format_arguments = {809 'projectId': self._serialize.url("project_id", project_id, 'str'),810 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')811 }812 url = self._client.format_url(url, **path_format_arguments)813 # Construct parameters814 query_parameters = {}815 if training_key is not None:816 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')817 # Construct headers818 header_parameters = {}819 header_parameters['Content-Type'] = 'application/json; charset=utf-8'820 if custom_headers:821 header_parameters.update(custom_headers)822 if training_key1 is not None:823 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')824 # Construct and send request825 request = self._client.post(url, query_parameters)826 response = self._client.send(request, header_parameters, **operation_config)827 if response.status_code not in [200]:828 raise HttpOperationError(self._deserialize, response)829 deserialized = None830 if response.status_code == 200:831 deserialized = self._deserialize('IterationModel', response)832 if raw:833 client_raw_response = ClientRawResponse(deserialized, response)834 return client_raw_response835 return deserialized836 def put_default_iteration(837 self, project_id, iteration_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):838 """839 :param project_id: Format - uuid.840 :type project_id: str841 :param iteration_id: Format - uuid.842 :type iteration_id: str843 :param training_key: subscription key in url844 :type training_key: str845 :param training_key1: subscription key in header846 :type training_key1: str847 :param dict custom_headers: headers that will be added to the request848 :param bool raw: returns the direct response alongside the849 deserialized response850 :param operation_config: :ref:`Operation configuration851 overrides<msrest:optionsforoperations>`.852 :rtype: None853 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`854 if raw=true855 :raises:856 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`857 """858 # Construct URL859 url = '/{projectId}/iterations/default/{iterationId}'860 path_format_arguments = {861 'projectId': self._serialize.url("project_id", project_id, 'str'),862 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')863 }864 url = self._client.format_url(url, **path_format_arguments)865 # Construct parameters866 query_parameters = {}867 if training_key is not None:868 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')869 # Construct headers870 header_parameters = {}871 header_parameters['Content-Type'] = 'application/json; charset=utf-8'872 if custom_headers:873 header_parameters.update(custom_headers)874 if training_key1 is not None:875 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')876 # Construct and send request877 request = self._client.put(url, query_parameters)878 response = self._client.send(request, header_parameters, **operation_config)879 if response.status_code not in [204]:880 raise HttpOperationError(self._deserialize, response)881 if raw:882 client_raw_response = ClientRawResponse(None, response)883 return client_raw_response884 def get_user_images_by_class(885 self, project_id, iteration_id, class_id, max_category_rank=None, max_count=None, continuation_token=None, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):886 """887 :param project_id: Format - uuid.888 :type project_id: str889 :param iteration_id: Format - uuid.890 :type iteration_id: str891 :param class_id: Format - uuid.892 :type class_id: str893 :param max_category_rank: Format - int32.894 :type max_category_rank: int895 :param max_count: Format - int32.896 :type max_count: int897 :param continuation_token:898 :type continuation_token: str899 :param training_key: subscription key in url900 :type training_key: str901 :param training_key1: subscription key in header902 :type training_key1: str903 :param dict custom_headers: headers that will be added to the request904 :param bool raw: returns the direct response alongside the905 deserialized response906 :param operation_config: :ref:`Operation configuration907 overrides<msrest:optionsforoperations>`.908 :rtype: :class:`UserImageResults <training.models.UserImageResults>`909 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`910 if raw=true911 :raises:912 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`913 """914 # Construct URL915 url = '/{projectId}/{iterationId}/userImages/class'916 path_format_arguments = {917 'projectId': self._serialize.url("project_id", project_id, 'str'),918 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')919 }920 url = self._client.format_url(url, **path_format_arguments)921 # Construct parameters922 query_parameters = {}923 query_parameters['classId'] = self._serialize.query("class_id", class_id, 'str')924 if max_category_rank is not None:925 query_parameters['maxCategoryRank'] = self._serialize.query("max_category_rank", max_category_rank, 'int')926 if max_count is not None:927 query_parameters['maxCount'] = self._serialize.query("max_count", max_count, 'int')928 if continuation_token is not None:929 query_parameters['continuationToken'] = self._serialize.query("continuation_token", continuation_token, 'str')930 if training_key is not None:931 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')932 # Construct headers933 header_parameters = {}934 header_parameters['Content-Type'] = 'application/json; charset=utf-8'935 if custom_headers:936 header_parameters.update(custom_headers)937 if training_key1 is not None:938 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')939 # Construct and send request940 request = self._client.get(url, query_parameters)941 response = self._client.send(request, header_parameters, **operation_config)942 if response.status_code not in [200]:943 raise HttpOperationError(self._deserialize, response)944 deserialized = None945 if response.status_code == 200:946 deserialized = self._deserialize('UserImageResults', response)947 if raw:948 client_raw_response = ClientRawResponse(deserialized, response)949 return client_raw_response950 return deserialized951 def get_user_images_by_time(952 self, project_id, iteration_id, start_time=None, end_time=None, ascending=None, max_count=None, continuation_token=None, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):953 """954 :param project_id: Format - uuid.955 :type project_id: str956 :param iteration_id: Format - uuid.957 :type iteration_id: str958 :param start_time: Format - date-time (as date-time in RFC3339).959 :type start_time: str960 :param end_time: Format - date-time (as date-time in RFC3339).961 :type end_time: str962 :param ascending:963 :type ascending: bool964 :param max_count: Format - int32.965 :type max_count: int966 :param continuation_token:967 :type continuation_token: str968 :param training_key: subscription key in url969 :type training_key: str970 :param training_key1: subscription key in header971 :type training_key1: str972 :param dict custom_headers: headers that will be added to the request973 :param bool raw: returns the direct response alongside the974 deserialized response975 :param operation_config: :ref:`Operation configuration976 overrides<msrest:optionsforoperations>`.977 :rtype: :class:`UserImageResults <training.models.UserImageResults>`978 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`979 if raw=true980 :raises:981 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`982 """983 # Construct URL984 url = '/{projectId}/{iterationId}/userImages/time'985 path_format_arguments = {986 'projectId': self._serialize.url("project_id", project_id, 'str'),987 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')988 }989 url = self._client.format_url(url, **path_format_arguments)990 # Construct parameters991 query_parameters = {}992 if start_time is not None:993 query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str')994 if end_time is not None:995 query_parameters['endTime'] = self._serialize.query("end_time", end_time, 'str')996 if ascending is not None:997 query_parameters['ascending'] = self._serialize.query("ascending", ascending, 'bool')998 if max_count is not None:999 query_parameters['maxCount'] = self._serialize.query("max_count", max_count, 'int')1000 if continuation_token is not None:1001 query_parameters['continuationToken'] = self._serialize.query("continuation_token", continuation_token, 'str')1002 if training_key is not None:1003 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1004 # Construct headers1005 header_parameters = {}1006 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1007 if custom_headers:1008 header_parameters.update(custom_headers)1009 if training_key1 is not None:1010 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1011 # Construct and send request1012 request = self._client.get(url, query_parameters)1013 response = self._client.send(request, header_parameters, **operation_config)1014 if response.status_code not in [200]:1015 raise HttpOperationError(self._deserialize, response)1016 deserialized = None1017 if response.status_code == 200:1018 deserialized = self._deserialize('UserImageResults', response)1019 if raw:1020 client_raw_response = ClientRawResponse(deserialized, response)1021 return client_raw_response1022 return deserialized1023 def archive_user_images(1024 self, project_id, iteration_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):1025 """1026 :param project_id: Format - uuid.1027 :type project_id: str1028 :param iteration_id: Format - uuid.1029 :type iteration_id: str1030 :param training_key: subscription key in url1031 :type training_key: str1032 :param training_key1: subscription key in header1033 :type training_key1: str1034 :param dict custom_headers: headers that will be added to the request1035 :param bool raw: returns the direct response alongside the1036 deserialized response1037 :param operation_config: :ref:`Operation configuration1038 overrides<msrest:optionsforoperations>`.1039 :rtype: None1040 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1041 if raw=true1042 :raises:1043 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1044 """1045 # Construct URL1046 url = '/{projectId}/{iterationId}/userImages/archive'1047 path_format_arguments = {1048 'projectId': self._serialize.url("project_id", project_id, 'str'),1049 'iterationId': self._serialize.url("iteration_id", iteration_id, 'str')1050 }1051 url = self._client.format_url(url, **path_format_arguments)1052 # Construct parameters1053 query_parameters = {}1054 if training_key is not None:1055 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1056 # Construct headers1057 header_parameters = {}1058 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1059 if custom_headers:1060 header_parameters.update(custom_headers)1061 if training_key1 is not None:1062 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1063 # Construct and send request1064 request = self._client.post(url, query_parameters)1065 response = self._client.send(request, header_parameters, **operation_config)1066 if response.status_code not in [204]:1067 raise HttpOperationError(self._deserialize, response)1068 if raw:1069 client_raw_response = ClientRawResponse(None, response)1070 return client_raw_response1071 def get_image(1072 self, project_id, image_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):1073 """Gets the requested image stream.1074 :param project_id: Format - uuid. The project guid.1075 :type project_id: str1076 :param image_id: Format - uuid. The image guid.1077 :type image_id: str1078 :param training_key: subscription key in url1079 :type training_key: str1080 :param training_key1: subscription key in header1081 :type training_key1: str1082 :param dict custom_headers: headers that will be added to the request1083 :param bool raw: returns the direct response alongside the1084 deserialized response1085 :param operation_config: :ref:`Operation configuration1086 overrides<msrest:optionsforoperations>`.1087 :rtype: object1088 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1089 if raw=true1090 :raises:1091 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1092 """1093 # Construct URL1094 url = '/{projectId}/images/{imageId}'1095 path_format_arguments = {1096 'projectId': self._serialize.url("project_id", project_id, 'str'),1097 'imageId': self._serialize.url("image_id", image_id, 'str')1098 }1099 url = self._client.format_url(url, **path_format_arguments)1100 # Construct parameters1101 query_parameters = {}1102 if training_key is not None:1103 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1104 # Construct headers1105 header_parameters = {}1106 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1107 if custom_headers:1108 header_parameters.update(custom_headers)1109 if training_key1 is not None:1110 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1111 # Construct and send request1112 request = self._client.get(url, query_parameters)1113 response = self._client.send(request, header_parameters, **operation_config)1114 if response.status_code not in [200]:1115 raise HttpOperationError(self._deserialize, response)1116 deserialized = None1117 if response.status_code == 200 and raw == False:1118 deserialized = self._deserialize('object', response)1119 if raw:1120 client_raw_response = ClientRawResponse(deserialized, response)1121 return client_raw_response1122 return deserialized1123 def get_thumbnail(1124 self, project_id, image_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):1125 """1126 :param project_id: Format - uuid.1127 :type project_id: str1128 :param image_id: Format - uuid.1129 :type image_id: str1130 :param training_key: subscription key in url1131 :type training_key: str1132 :param training_key1: subscription key in header1133 :type training_key1: str1134 :param dict custom_headers: headers that will be added to the request1135 :param bool raw: returns the direct response alongside the1136 deserialized response1137 :param operation_config: :ref:`Operation configuration1138 overrides<msrest:optionsforoperations>`.1139 :rtype: object1140 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1141 if raw=true1142 :raises:1143 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1144 """1145 # Construct URL1146 url = '/{projectId}/thumbnails/{imageId}'1147 path_format_arguments = {1148 'projectId': self._serialize.url("project_id", project_id, 'str'),1149 'imageId': self._serialize.url("image_id", image_id, 'str')1150 }1151 url = self._client.format_url(url, **path_format_arguments)1152 # Construct parameters1153 query_parameters = {}1154 if training_key is not None:1155 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1156 # Construct headers1157 header_parameters = {}1158 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1159 if custom_headers:1160 header_parameters.update(custom_headers)1161 if training_key1 is not None:1162 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1163 # Construct and send request1164 request = self._client.get(url, query_parameters)1165 response = self._client.send(request, header_parameters, **operation_config)1166 if response.status_code not in [200]:1167 raise HttpOperationError(self._deserialize, response)1168 deserialized = None1169 if response.status_code == 200:1170 deserialized = self._deserialize('object', response)1171 if raw:1172 client_raw_response = ClientRawResponse(deserialized, response)1173 return client_raw_response1174 return deserialized1175 def post_image_urls_for_class(1176 self, project_id, class_id, training_key=None, training_key1=None, image_url_batch=None, custom_headers=None, raw=False, **operation_config):1177 """1178 :param project_id: Format - uuid.1179 :type project_id: str1180 :param class_id: Format - uuid.1181 :type class_id: str1182 :param training_key: subscription key in url1183 :type training_key: str1184 :param training_key1: subscription key in header1185 :type training_key1: str1186 :param image_url_batch:1187 :type image_url_batch: :class:`ImageUrlBatch1188 <training.models.ImageUrlBatch>`1189 :param dict custom_headers: headers that will be added to the request1190 :param bool raw: returns the direct response alongside the1191 deserialized response1192 :param operation_config: :ref:`Operation configuration1193 overrides<msrest:optionsforoperations>`.1194 :rtype: :class:`ImageUploadSummary1195 <training.models.ImageUploadSummary>`1196 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1197 if raw=true1198 :raises:1199 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1200 """1201 # Construct URL1202 url = '/{projectId}/images/{classId}/url'1203 path_format_arguments = {1204 'projectId': self._serialize.url("project_id", project_id, 'str'),1205 'classId': self._serialize.url("class_id", class_id, 'str')1206 }1207 url = self._client.format_url(url, **path_format_arguments)1208 # Construct parameters1209 query_parameters = {}1210 if training_key is not None:1211 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1212 # Construct headers1213 header_parameters = {}1214 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1215 if custom_headers:1216 header_parameters.update(custom_headers)1217 if training_key1 is not None:1218 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1219 # Construct body1220 if image_url_batch is not None:1221 body_content = self._serialize.body(image_url_batch, 'ImageUrlBatch')1222 else:1223 body_content = None1224 # Construct and send request1225 request = self._client.post(url, query_parameters)1226 response = self._client.send(1227 request, header_parameters, body_content, **operation_config)1228 if response.status_code not in [200]:1229 raise HttpOperationError(self._deserialize, response)1230 deserialized = None1231 if response.status_code == 200:1232 deserialized = self._deserialize('ImageUploadSummary', response)1233 if raw:1234 client_raw_response = ClientRawResponse(deserialized, response)1235 return client_raw_response1236 return deserialized1237 def post_images_for_class(1238 self, project_id, class_id, image_data, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):1239 """1240 :param project_id: Format - uuid.1241 :type project_id: str1242 :param class_id: Format - uuid.1243 :type class_id: str1244 :param image_data:1245 :type image_data: str1246 :param training_key: subscription key in url1247 :type training_key: str1248 :param training_key1: subscription key in header1249 :type training_key1: str1250 :param dict custom_headers: headers that will be added to the request1251 :param bool raw: returns the direct response alongside the1252 deserialized response1253 :param operation_config: :ref:`Operation configuration1254 overrides<msrest:optionsforoperations>`.1255 :rtype: :class:`ImageUploadSummary1256 <training.models.ImageUploadSummary>`1257 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1258 if raw=true1259 :raises:1260 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1261 """1262 # Construct URL1263 url = '/{projectId}/images/{classId}/image'1264 path_format_arguments = {1265 'projectId': self._serialize.url("project_id", project_id, 'str'),1266 'classId': self._serialize.url("class_id", class_id, 'str')1267 }1268 url = self._client.format_url(url, **path_format_arguments)1269 # Construct parameters1270 query_parameters = {}1271 if training_key is not None:1272 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1273 # Construct headers1274 header_parameters = {}1275 header_parameters['Content-Type'] = 'multipart/form-data'1276 if custom_headers:1277 header_parameters.update(custom_headers)1278 if training_key1 is not None:1279 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1280 # Construct form data1281 form_data_content = {1282 'imageData': image_data,1283 }1284 # Construct and send request1285 request = self._client.post(url, query_parameters)1286 response = self._client.send_formdata(1287 request, header_parameters, form_data_content, **operation_config)1288 if response.status_code not in [200]:1289 raise HttpOperationError(self._deserialize, response)1290 deserialized = None1291 if response.status_code == 200:1292 deserialized = self._deserialize('ImageUploadSummary', response)1293 if raw:1294 client_raw_response = ClientRawResponse(deserialized, response)1295 return client_raw_response1296 return deserialized1297 def delete_images(1298 self, project_id, training_key=None, training_key1=None, image_ids=None, custom_headers=None, raw=False, **operation_config):1299 """1300 :param project_id: Format - uuid.1301 :type project_id: str1302 :param training_key: subscription key in url1303 :type training_key: str1304 :param training_key1: subscription key in header1305 :type training_key1: str1306 :param image_ids:1307 :type image_ids: list of str1308 :param dict custom_headers: headers that will be added to the request1309 :param bool raw: returns the direct response alongside the1310 deserialized response1311 :param operation_config: :ref:`Operation configuration1312 overrides<msrest:optionsforoperations>`.1313 :rtype: None1314 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1315 if raw=true1316 :raises:1317 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1318 """1319 # Construct URL1320 url = '/{projectId}/images'1321 path_format_arguments = {1322 'projectId': self._serialize.url("project_id", project_id, 'str')1323 }1324 url = self._client.format_url(url, **path_format_arguments)1325 # Construct parameters1326 query_parameters = {}1327 if training_key is not None:1328 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1329 # Construct headers1330 header_parameters = {}1331 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1332 if custom_headers:1333 header_parameters.update(custom_headers)1334 if training_key1 is not None:1335 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1336 # Construct body1337 if image_ids is not None:1338 body_content = self._serialize.body(image_ids, '[str]')1339 else:1340 body_content = None1341 # Construct and send request1342 request = self._client.delete(url, query_parameters)1343 response = self._client.send(1344 request, header_parameters, body_content, **operation_config)1345 if response.status_code not in [204]:1346 raise HttpOperationError(self._deserialize, response)1347 if raw:1348 client_raw_response = ClientRawResponse(None, response)1349 return client_raw_response1350 def get_images(1351 self, project_id, iteration_id=None, tag_ids=None, performance_filter=None, order_by=None, take=50, skip=0, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):1352 """This API supports batching and range selection. By default it will only1353 return first 50 images matching images.1354 Use the {take} and {skip} parameters to control how many images to1355 return in a given batch.1356 If the total number of images is less than ({skip} + {take})1357 the number of images returned will be less than {take}.1358 :param project_id: Format - uuid. The project id1359 :type project_id: str1360 :param iteration_id: Format - uuid. The iteration id. This will1361 default to the current iteration1362 :type iteration_id: str1363 :param tag_ids: An optional list of tags ids to filter the images. For1364 example, the API only return images tagged1365 with "Dog" and "Cat" if specified. Otherwise, it will consider all1366 tags1367 :type tag_ids: str1368 :param performance_filter: The performance filter to apply. This will1369 only be valid when querying trained iterations. Possible values1370 include: 'None', 'Correct', 'Incorrect'1371 :type performance_filter: str1372 :param order_by: The ordering. Defaults to newest. Possible values1373 include: 'Newest', 'Oldest'1374 :type order_by: str1375 :param take: Format - int32. Maximum number of images to return.1376 Defaults to 501377 :type take: int1378 :param skip: Format - int32. How many images should be skipped before1379 begining the image batch. Defaults to 01380 :type skip: int1381 :param training_key: subscription key in url1382 :type training_key: str1383 :param training_key1: subscription key in header1384 :type training_key1: str1385 :param dict custom_headers: headers that will be added to the request1386 :param bool raw: returns the direct response alongside the1387 deserialized response1388 :param operation_config: :ref:`Operation configuration1389 overrides<msrest:optionsforoperations>`.1390 :rtype: list of :class:`ImageModel <training.models.ImageModel>`1391 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1392 if raw=true1393 :raises:1394 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1395 """1396 # Construct URL1397 url = '/{projectId}/images'1398 path_format_arguments = {1399 'projectId': self._serialize.url("project_id", project_id, 'str')1400 }1401 url = self._client.format_url(url, **path_format_arguments)1402 # Construct parameters1403 query_parameters = {}1404 if iteration_id is not None:1405 query_parameters['iterationId'] = self._serialize.query("iteration_id", iteration_id, 'str')1406 if tag_ids is not None:1407 query_parameters['tagIds'] = self._serialize.query("tag_ids", tag_ids, 'str')1408 if performance_filter is not None:1409 query_parameters['performanceFilter'] = self._serialize.query("performance_filter", performance_filter, 'str')1410 if order_by is not None:1411 query_parameters['orderBy'] = self._serialize.query("order_by", order_by, 'str')1412 if take is not None:1413 query_parameters['take'] = self._serialize.query("take", take, 'int')1414 if skip is not None:1415 query_parameters['skip'] = self._serialize.query("skip", skip, 'int')1416 if training_key is not None:1417 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1418 # Construct headers1419 header_parameters = {}1420 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1421 if custom_headers:1422 header_parameters.update(custom_headers)1423 if training_key1 is not None:1424 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1425 # Construct and send request1426 request = self._client.get(url, query_parameters)1427 response = self._client.send(request, header_parameters, **operation_config)1428 if response.status_code not in [200]:1429 raise HttpOperationError(self._deserialize, response)1430 deserialized = None1431 if response.status_code == 200:1432 deserialized = self._deserialize('[ImageModel]', response)1433 if raw:1434 client_raw_response = ClientRawResponse(deserialized, response)1435 return client_raw_response1436 return deserialized1437 def change_image_label(1438 self, project_id, image_id, class_id, training_key=None, training_key1=None, image_region=None, custom_headers=None, raw=False, **operation_config):1439 """Changes the image's class.1440 :param project_id: Format - uuid. The project id.1441 :type project_id: str1442 :param image_id: Format - uuid. The image id.1443 :type image_id: str1444 :param class_id: Format - uuid. The class id.1445 :type class_id: str1446 :param training_key: subscription key in url1447 :type training_key: str1448 :param training_key1: subscription key in header1449 :type training_key1: str1450 :param image_region:1451 :type image_region: :class:`ImageRegion <training.models.ImageRegion>`1452 :param dict custom_headers: headers that will be added to the request1453 :param bool raw: returns the direct response alongside the1454 deserialized response1455 :param operation_config: :ref:`Operation configuration1456 overrides<msrest:optionsforoperations>`.1457 :rtype: :class:`ImageModelObsolete1458 <training.models.ImageModelObsolete>`1459 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1460 if raw=true1461 :raises:1462 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1463 """1464 # Construct URL1465 url = '/{projectId}/image/{imageId}'1466 path_format_arguments = {1467 'projectId': self._serialize.url("project_id", project_id, 'str'),1468 'imageId': self._serialize.url("image_id", image_id, 'str')1469 }1470 url = self._client.format_url(url, **path_format_arguments)1471 # Construct parameters1472 query_parameters = {}1473 query_parameters['classId'] = self._serialize.query("class_id", class_id, 'str')1474 if training_key is not None:1475 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1476 # Construct headers1477 header_parameters = {}1478 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1479 if custom_headers:1480 header_parameters.update(custom_headers)1481 if training_key1 is not None:1482 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1483 # Construct body1484 if image_region is not None:1485 body_content = self._serialize.body(image_region, 'ImageRegion')1486 else:1487 body_content = None1488 # Construct and send request1489 request = self._client.patch(url, query_parameters)1490 response = self._client.send(1491 request, header_parameters, body_content, **operation_config)1492 if response.status_code not in [200]:1493 raise HttpOperationError(self._deserialize, response)1494 deserialized = None1495 if response.status_code == 200:1496 deserialized = self._deserialize('ImageModelObsolete', response)1497 if raw:1498 client_raw_response = ClientRawResponse(deserialized, response)1499 return client_raw_response1500 return deserialized1501 def get_image_thumbnail(1502 self, project_id, image_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):1503 """Gets the requested thumbnail stream for the image.1504 :param project_id: Format - uuid. The project guid.1505 :type project_id: str1506 :param image_id: Format - uuid. The image guid.1507 :type image_id: str1508 :param training_key: subscription key in url1509 :type training_key: str1510 :param training_key1: subscription key in header1511 :type training_key1: str1512 :param dict custom_headers: headers that will be added to the request1513 :param bool raw: returns the direct response alongside the1514 deserialized response1515 :param operation_config: :ref:`Operation configuration1516 overrides<msrest:optionsforoperations>`.1517 :rtype: object1518 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1519 if raw=true1520 :raises:1521 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1522 """1523 # Construct URL1524 url = '/{projectId}/images/{imageId}/thumbnail'1525 path_format_arguments = {1526 'projectId': self._serialize.url("project_id", project_id, 'str'),1527 'imageId': self._serialize.url("image_id", image_id, 'str')1528 }1529 url = self._client.format_url(url, **path_format_arguments)1530 # Construct parameters1531 query_parameters = {}1532 if training_key is not None:1533 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1534 # Construct headers1535 header_parameters = {}1536 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1537 if custom_headers:1538 header_parameters.update(custom_headers)1539 if training_key1 is not None:1540 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1541 # Construct and send request1542 request = self._client.get(url, query_parameters)1543 response = self._client.send(request, header_parameters, **operation_config)1544 if response.status_code not in [200]:1545 raise HttpOperationError(self._deserialize, response)1546 deserialized = None1547 if response.status_code == 200:1548 deserialized = self._deserialize('object', response)1549 if raw:1550 client_raw_response = ClientRawResponse(deserialized, response)1551 return client_raw_response1552 return deserialized1553 def post_image_urls(1554 self, project_id, training_key=None, training_key1=None, image_url_create_batch=None, custom_headers=None, raw=False, **operation_config):1555 """Adds the provided images to the current project iteration.1556 :param project_id: Format - uuid. The project id.1557 :type project_id: str1558 :param training_key: subscription key in url1559 :type training_key: str1560 :param training_key1: subscription key in header1561 :type training_key1: str1562 :param image_url_create_batch: Image urls and tag ids1563 :type image_url_create_batch: :class:`ImageUrlCreateBatch1564 <training.models.ImageUrlCreateBatch>`1565 :param dict custom_headers: headers that will be added to the request1566 :param bool raw: returns the direct response alongside the1567 deserialized response1568 :param operation_config: :ref:`Operation configuration1569 overrides<msrest:optionsforoperations>`.1570 :rtype: :class:`ImageUploadSummary1571 <training.models.ImageUploadSummary>`1572 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1573 if raw=true1574 :raises:1575 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1576 """1577 # Construct URL1578 url = '/{projectId}/images/url'1579 path_format_arguments = {1580 'projectId': self._serialize.url("project_id", project_id, 'str')1581 }1582 url = self._client.format_url(url, **path_format_arguments)1583 # Construct parameters1584 query_parameters = {}1585 if training_key is not None:1586 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1587 # Construct headers1588 header_parameters = {}1589 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1590 if custom_headers:1591 header_parameters.update(custom_headers)1592 if training_key1 is not None:1593 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1594 # Construct body1595 if image_url_create_batch is not None:1596 body_content = self._serialize.body(image_url_create_batch, 'ImageUrlCreateBatch')1597 else:1598 body_content = None1599 # Construct and send request1600 request = self._client.post(url, query_parameters)1601 response = self._client.send(1602 request, header_parameters, body_content, **operation_config)1603 if response.status_code not in [200]:1604 raise HttpOperationError(self._deserialize, response)1605 deserialized = None1606 if response.status_code == 200:1607 deserialized = self._deserialize('ImageUploadSummary', response)1608 if raw:1609 client_raw_response = ClientRawResponse(deserialized, response)1610 return client_raw_response1611 return deserialized1612 def post_images(1613 self, project_id, image_data, image_data1, training_key=None, training_key1=None, tag_ids=None, custom_headers=None, raw=False, **operation_config):1614 """Adds the provided images to the current project iteration.1615 :param project_id: Format - uuid. The project id.1616 :type project_id: str1617 :param image_data:1618 :type image_data: str1619 :param image_data1:1620 :type image_data1: str1621 :param training_key: subscription key in url1622 :type training_key: str1623 :param training_key1: subscription key in header1624 :type training_key1: str1625 :param tag_ids: The tags ids to associate with the image batch.1626 :type tag_ids: list of str1627 :param dict custom_headers: headers that will be added to the request1628 :param bool raw: returns the direct response alongside the1629 deserialized response1630 :param operation_config: :ref:`Operation configuration1631 overrides<msrest:optionsforoperations>`.1632 :rtype: :class:`ImageUploadSummary1633 <training.models.ImageUploadSummary>`1634 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1635 if raw=true1636 :raises:1637 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1638 """1639 # Construct URL1640 url = '/{projectId}/images/image'1641 path_format_arguments = {1642 'projectId': self._serialize.url("project_id", project_id, 'str')1643 }1644 url = self._client.format_url(url, **path_format_arguments)1645 # Construct parameters1646 query_parameters = {}1647 if training_key is not None:1648 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1649 # Construct headers1650 header_parameters = {}1651 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1652 if custom_headers:1653 header_parameters.update(custom_headers)1654 if training_key1 is not None:1655 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1656 # Construct body1657 if tag_ids is not None:1658 body_content = self._serialize.body(tag_ids, '[str]')1659 else:1660 body_content = None1661 # Construct and send request1662 request = self._client.post(url, query_parameters)1663 response = self._client.send(1664 request, header_parameters, body_content, **operation_config)1665 if response.status_code not in [200]:1666 raise HttpOperationError(self._deserialize, response)1667 deserialized = None1668 if response.status_code == 200:1669 deserialized = self._deserialize('ImageUploadSummary', response)1670 if raw:1671 client_raw_response = ClientRawResponse(deserialized, response)1672 return client_raw_response1673 return deserialized1674 def post_image_label(1675 self, project_id, image_id, training_key=None, training_key1=None, image_label_create_model=None, custom_headers=None, raw=False, **operation_config):1676 """1677 :param project_id: Format - uuid.1678 :type project_id: str1679 :param image_id: Format - uuid.1680 :type image_id: str1681 :param training_key: subscription key in url1682 :type training_key: str1683 :param training_key1: subscription key in header1684 :type training_key1: str1685 :param image_label_create_model:1686 :type image_label_create_model: :class:`ImageLabelCreateModel1687 <training.models.ImageLabelCreateModel>`1688 :param dict custom_headers: headers that will be added to the request1689 :param bool raw: returns the direct response alongside the1690 deserialized response1691 :param operation_config: :ref:`Operation configuration1692 overrides<msrest:optionsforoperations>`.1693 :rtype: :class:`ImageModel <training.models.ImageModel>`1694 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1695 if raw=true1696 :raises:1697 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1698 """1699 # Construct URL1700 url = '/{projectId}/image/{imageId}/label'1701 path_format_arguments = {1702 'projectId': self._serialize.url("project_id", project_id, 'str'),1703 'imageId': self._serialize.url("image_id", image_id, 'str')1704 }1705 url = self._client.format_url(url, **path_format_arguments)1706 # Construct parameters1707 query_parameters = {}1708 if training_key is not None:1709 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1710 # Construct headers1711 header_parameters = {}1712 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1713 if custom_headers:1714 header_parameters.update(custom_headers)1715 if training_key1 is not None:1716 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1717 # Construct body1718 if image_label_create_model is not None:1719 body_content = self._serialize.body(image_label_create_model, 'ImageLabelCreateModel')1720 else:1721 body_content = None1722 # Construct and send request1723 request = self._client.post(url, query_parameters)1724 response = self._client.send(1725 request, header_parameters, body_content, **operation_config)1726 if response.status_code not in [200]:1727 raise HttpOperationError(self._deserialize, response)1728 deserialized = None1729 if response.status_code == 200:1730 deserialized = self._deserialize('ImageModel', response)1731 if raw:1732 client_raw_response = ClientRawResponse(deserialized, response)1733 return client_raw_response1734 return deserialized1735 def delete_image_label(1736 self, project_id, image_id, label_id, training_key=None, training_key1=None, custom_headers=None, raw=False, **operation_config):1737 """1738 :param project_id: Format - uuid.1739 :type project_id: str1740 :param image_id: Format - uuid.1741 :type image_id: str1742 :param label_id: Format - uuid.1743 :type label_id: str1744 :param training_key: subscription key in url1745 :type training_key: str1746 :param training_key1: subscription key in header1747 :type training_key1: str1748 :param dict custom_headers: headers that will be added to the request1749 :param bool raw: returns the direct response alongside the1750 deserialized response1751 :param operation_config: :ref:`Operation configuration1752 overrides<msrest:optionsforoperations>`.1753 :rtype: :class:`ImageModel <training.models.ImageModel>`1754 :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`1755 if raw=true1756 :raises:1757 :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`1758 """1759 # Construct URL1760 url = '/{projectId}/image/{imageId}/label/{labelId}'1761 path_format_arguments = {1762 'projectId': self._serialize.url("project_id", project_id, 'str'),1763 'imageId': self._serialize.url("image_id", image_id, 'str'),1764 'labelId': self._serialize.url("label_id", label_id, 'str')1765 }1766 url = self._client.format_url(url, **path_format_arguments)1767 # Construct parameters1768 query_parameters = {}1769 if training_key is not None:1770 query_parameters['Training-key'] = self._serialize.query("training_key", training_key, 'str')1771 # Construct headers1772 header_parameters = {}1773 header_parameters['Content-Type'] = 'application/json; charset=utf-8'1774 if custom_headers:1775 header_parameters.update(custom_headers)1776 if training_key1 is not None:1777 header_parameters['Training-key'] = self._serialize.header("training_key1", training_key1, 'str')1778 # Construct and send request1779 request = self._client.delete(url, query_parameters)1780 response = self._client.send(request, header_parameters, **operation_config)1781 if response.status_code not in [200]:1782 raise HttpOperationError(self._deserialize, response)1783 deserialized = None1784 if response.status_code == 200:1785 deserialized = self._deserialize('ImageModel', response)1786 if raw:1787 client_raw_response = ClientRawResponse(deserialized, response)1788 return client_raw_response...

Full Screen

Full Screen

ast.py

Source:ast.py Github

copy

Full Screen

...45 'FunctionCall',46 ]47def serialize(xp_ast):48 '''Serialize an XPath AST as a valid XPath expression.'''49 return ''.join(_serialize(xp_ast))50def _serialize(xp_ast):51 '''Generate token strings which, when joined together, form a valid52 XPath serialization of the AST.'''53 if hasattr(xp_ast, '_serialize'):54 for tok in xp_ast._serialize():55 yield tok56 elif isinstance(xp_ast, string_types):57 # strings in serialized xpath needed to be quoted58 # (e.g. for use in paths, comparisons, etc)59 # using repr to quote them; for unicode, the leading60 # u (u'') needs to be removed.61 yield repr(xp_ast).lstrip('u')62 else:63 yield str(xp_ast)64class UnaryExpression(object):65 '''A unary XPath expression. Practially, this means -foo.'''66 def __init__(self, op, right):67 self.op = op68 '''the operator used in the expression'''69 self.right = right70 '''the expression the operator is applied to'''71 def __repr__(self):72 return '<%s %s %s>' % (self.__class__.__name__,73 self.op, serialize(self.right))74 def _serialize(self):75 yield self.op76 for tok in _serialize(self.right):77 yield tok78KEYWORDS = set(['or', 'and', 'div', 'mod'])79class BinaryExpression(object):80 '''Any binary XPath expression. a/b; a and b; a | b.'''81 def __init__(self, left, op, right):82 self.left = left83 '''the left side of the binary expression'''84 self.op = op85 '''the operator of the binary expression'''86 self.right = right87 '''the right side of the binary expression'''88 def __repr__(self):89 return '<%s %s %s %s>' % (self.__class__.__name__,90 serialize(self.left), self.op, serialize(self.right))91 def _serialize(self):92 for tok in _serialize(self.left):93 yield tok94 if self.op in KEYWORDS:95 yield ' '96 yield self.op97 yield ' '98 else:99 yield self.op100 for tok in _serialize(self.right):101 yield tok102class PredicatedExpression(object):103 '''A filtered XPath expression. $var[1]; (a or b)[foo][@bar].'''104 def __init__(self, base, predicates=None):105 self.base = base106 '''the base expression to be filtered'''107 self.predicates = predicates or []108 '''a list of filter predicates'''109 def __repr__(self):110 return '<%s %s>' % (self.__class__.__name__,111 serialize(self))112 def append_predicate(self, pred):113 self.predicates.append(pred)114 def _serialize(self):115 yield '('116 for tok in _serialize(self.base):117 yield tok118 yield ')'119 for pred in self.predicates:120 yield '['121 for tok in _serialize(pred):122 yield tok123 yield ']'124class AbsolutePath(object):125 '''An absolute XPath path. /a/b/c; //a/ancestor:b/@c.'''126 def __init__(self, op='/', relative=None):127 self.op = op128 '''the operator used to root the expression'''129 self.relative = relative130 '''the relative path after the absolute root operator'''131 def __repr__(self):132 if self.relative:133 return '<%s %s %s>' % (self.__class__.__name__,134 self.op, serialize(self.relative))135 else:136 return '<%s %s>' % (self.__class__.__name__, self.op)137 def _serialize(self):138 yield self.op139 for tok in _serialize(self.relative):140 yield tok141class Step(object):142 '''A single step in a relative path. a; @b; text(); parent::foo:bar[5].'''143 def __init__(self, axis, node_test, predicates):144 self.axis = axis145 '''the step's axis, or @ or None if abbreviated or undefined'''146 self.node_test = node_test147 '''a NameTest or NodeType object describing the test represented'''148 self.predicates = predicates149 '''a list of predicates filtering the step'''150 def __repr__(self):151 return '<%s %s>' % (self.__class__.__name__,152 serialize(self))153 def _serialize(self):154 if self.axis == '@':155 yield '@'156 elif self.axis:157 yield self.axis158 yield '::'159 for tok in self.node_test._serialize():160 yield tok161 for predicate in self.predicates:162 yield '['163 for tok in _serialize(predicate):164 yield tok165 yield ']'166class NameTest(object):167 '''An element name node test for a Step.'''168 def __init__(self, prefix, name):169 self.prefix = prefix170 '''the namespace prefix used for the test, or None if unset'''171 self.name = name172 '''the node name used for the test, or *'''173 def __repr__(self):174 return '<%s %s>' % (self.__class__.__name__,175 serialize(self))176 def _serialize(self):177 if self.prefix:178 yield self.prefix179 yield ':'180 yield self.name181 def __str__(self):182 return ''.join(self._serialize())183class NodeType(object):184 '''A node type node test for a Step.'''185 def __init__(self, name, literal=None):186 self.name = name187 '''the node type name, such as node or text'''188 self.literal = literal189 '''the argument to the node specifier. XPath allows these only for190 processing-instruction() node tests.'''191 def __repr__(self):192 return '<%s %s>' % (self.__class__.__name__,193 serialize(self))194 def _serialize(self):195 yield self.name196 yield '('197 if self.literal is not None:198 for tok in _serialize(self.literal):199 yield self.literal200 yield ')'201 def __str__(self):202 return ''.join(self._serialize())203class AbbreviatedStep(object):204 '''An abbreviated XPath step. . or ..'''205 def __init__(self, abbr):206 self.abbr = abbr207 '''the abbreviated step'''208 def __repr__(self):209 return '<%s %s>' % (self.__class__.__name__,210 serialize(self))211 def _serialize(self):212 yield self.abbr213class VariableReference(object):214 '''An XPath variable reference. $foo; $myns:foo.'''215 def __init__(self, name):216 self.name = name217 '''a tuple (prefix, localname) containing the variable name'''218 def __repr__(self):219 return '<%s %s>' % (self.__class__.__name__,220 serialize(self))221 def _serialize(self):222 yield '$'223 prefix, localname = self.name224 if prefix:225 yield prefix226 yield ':'227 yield localname228class FunctionCall(object):229 '''An XPath function call. foo(); my:foo(1); foo(1, 'a', $var).'''230 def __init__(self, prefix, name, args):231 self.prefix = prefix232 '''the namespace prefix, or None if unspecified'''233 self.name = name234 '''the local function name'''235 self.args = args236 '''a list of argument expressions'''237 def __repr__(self):238 return '<%s %s>' % (self.__class__.__name__,239 serialize(self))240 def _serialize(self):241 if self.prefix:242 yield self.prefix243 yield ':'244 yield self.name245 yield '('246 if self.args:247 for tok in _serialize(self.args[0]):248 yield tok249 for arg in self.args[1:]:250 yield ','251 for tok in _serialize(arg):252 yield tok...

Full Screen

Full Screen

inmemory.py

Source:inmemory.py Github

copy

Full Screen

...69 def load_from_csv(self, inst_csv, ccy_csv, exch_csv):70 load_inst_from_csv(self, inst_csv)71 load_ccy_from_csv(self, ccy_csv)72 load_exch_from_csv(self, exch_csv)73 def _serialize(self, serializable):74 return get_model_id(serializable), model_to_dict(serializable)75 # RefDataStore76 def save_instrument(self, instrument):77 id, packed = self._serialize(instrument)78 self.instruments[id] = packed79 def save_exchange(self, exchange):80 id, packed = self._serialize(exchange)81 self.exchanges[id] = packed82 def save_currency(self, currency):83 id, packed = self._serialize(currency)84 self.currencies[id] = packed85 # TimeSeriesDataStore86 def save_bar(self, bar):87 id, packed = self._serialize(bar)88 self.bars[id] = packed89 def save_quote(self, quote):90 id, packed = self._serialize(quote)91 self.quotes[id] = packed92 def save_trade(self, trade):93 id, packed = self._serialize(trade)94 self.trades[id] = packed95 def save_market_depth(self, market_depth):96 id, packed = self._serialize(market_depth)97 self.market_depths[id] = packed98 def save_time_series(self, timeseries):99 id, packed = self._serialize(timeseries)100 self.time_series[id] = packed101 def __matches_data(self, data, inst_id, from_timestamp, to_timestamp):102 return inst_id == data.inst_id and data.timestamp >= from_timestamp and data.timestamp < to_timestamp103 def load_bars(self, sub_key):104 from_timestamp = date_to_unixtimemillis(sub_key.from_date)105 to_timestamp = date_to_unixtimemillis(sub_key.to_date)106 return [bar for bar in self.load_all('bars') if self.__matches_data(bar, sub_key.inst_id, from_timestamp,107 to_timestamp) and bar.type == sub_key.subscription_type.bar_type and bar.size == sub_key.subscription_type.bar_size]108 def load_quotes(self, sub_key):109 from_timestamp = date_to_unixtimemillis(sub_key.from_date)110 to_timestamp = date_to_unixtimemillis(sub_key.to_date)111 return [quote for quote in self.load_all('quotes') if112 self.__matches_data(quote, sub_key.inst_id, from_timestamp, to_timestamp)]113 def load_trades(self, sub_key):114 from_timestamp = date_to_unixtimemillis(sub_key.from_date)115 to_timestamp = date_to_unixtimemillis(sub_key.to_date)116 return [trade for trade in self.load_all('trades') if117 self.__matches_data(trade, sub_key.inst_id, from_timestamp, to_timestamp)]118 def load_market_depths(self, sub_key):119 from_timestamp = date_to_unixtimemillis(sub_key.from_date)120 to_timestamp = date_to_unixtimemillis(sub_key.to_date)121 return [market_depth for market_depth in self.load_all('market_depths') if122 self.__matches_data(market_depth, sub_key.inst_id, from_timestamp, to_timestamp)]123 # TradeDataStore124 def save_account(self, account):125 id, packed = self._serialize(account)126 self.accounts[id] = packed127 def save_portfolio(self, portfolio):128 id, packed = self._serialize(portfolio)129 self.portfolios[id] = packed130 def save_order(self, order):131 id, packed = self._serialize(order)132 self.orders[id] = packed133 def save_strategy(self, strategy):134 id, packed = self._serialize(strategy)135 self.strategies[id] = packed136 # def save_config(self, config):137 # id, packed = self._serialize(config)138 # self.configs[id] = packed139 def save_account_update(self, account_update):140 id, packed = self._serialize(account_update)141 self.account_updates[id] = packed142 def save_portfolio_update(self, portfolio_update):143 id, packed = self._serialize(portfolio_update)144 self.portfolio_updates[id] = packed145 def save_new_order_req(self, new_order_req):146 id, packed = self._serialize(new_order_req)147 self.new_order_reqs[id] = packed148 def save_ord_cancel_req(self, ord_cancel_req):149 id, packed = self._serialize(ord_cancel_req)150 self.ord_cancel_reqs[id] = packed151 def save_ord_replace_req(self, ord_replace_req):152 id, packed = self._serialize(ord_replace_req)153 self.ord_replace_reqs[id] = packed154 def save_exec_report(self, exec_report):155 id, packed = self._serialize(exec_report)156 self.exec_reports[id] = packed157 def save_ord_status_upd(self, ord_status_upd):158 id, packed = self._serialize(ord_status_upd)159 self.ord_status_upds[id] = packed160 # SequenceDataStore161 def save_sequence(self, key, seq):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful