def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None): """Makes the HTTP request using RESTClient.""" if method == "GET": return self.rest_client.GET(url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers) elif method == "HEAD": return self.rest_client.HEAD(url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers) elif method == "OPTIONS": return self.rest_client.OPTIONS(url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout) elif method == "POST": return self.rest_client.POST(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "PUT": return self.rest_client.PUT(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "PATCH": return self.rest_client.PATCH(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "DELETE": return self.rest_client.DELETE(url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) else: raise ApiValueError( "http method must be `GET`, `HEAD`, `OPTIONS`," " `POST`, `PATCH`, `PUT` or `DELETE`." )
def update_params_for_auth(self, headers, querys, auth_settings): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. """ if not auth_settings: return for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: if auth_setting['in'] == 'cookie': headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': querys.append((auth_setting['key'], auth_setting['value'])) else: raise ApiValueError( 'Authentication token must be in `query` or `header`' )
def create_project_with_http_info(self, body, **kwargs): # noqa: E501 """Create a Project # noqa: E501 Create a Project. A Project is a collection of Documents. A Project is associated with exactly one Memory. Projects appear in the dashboard of the web app. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_project_with_http_info(body, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param ProjectParameters body: (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(Project, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['body'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_project" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'body' is set if self.api_client.client_side_validation and ('body' not in local_var_params or # noqa: E501 local_var_params['body'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `body` when calling `create_project`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/projects', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='Project', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def get_project_status_with_http_info(self, id, **kwargs): # noqa: E501 """Retrieve Project status # noqa: E501 Retrieve the status of a Project. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_project_status_with_http_info(id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int id: A unique Project identifier. (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(ProjectStatus, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method get_project_status" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ('id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `id` when calling `get_project_status`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'id' in local_var_params and local_var_params['id'] is not None: # noqa: E501 query_params.append(('id', local_var_params['id'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/projects/status', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ProjectStatus', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def register_segment_with_http_info(self, source, srclang, trglang, **kwargs): # noqa: E501 """Register a segment # noqa: E501 Register a source string for interactive translation. The `source_hash` value that is returned by this request is required by the `prefix` parameter for the translation endpoint. The maximum source length is 5,000 characters. Usage charges apply to this endpoint for production REST API keys. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.register_segment_with_http_info(source, srclang, trglang, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str source: A source string to be registered. (required) :param str srclang: An ISO 639-1 language code. (required) :param str trglang: An ISO 639-1 language code. (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(TranslateRegisterResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['source', 'srclang', 'trglang'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method register_segment" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'source' is set if self.api_client.client_side_validation and ( 'source' not in local_var_params or # noqa: E501 local_var_params['source'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `source` when calling `register_segment`" ) # noqa: E501 # verify the required parameter 'srclang' is set if self.api_client.client_side_validation and ( 'srclang' not in local_var_params or # noqa: E501 local_var_params['srclang'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `srclang` when calling `register_segment`" ) # noqa: E501 # verify the required parameter 'trglang' is set if self.api_client.client_side_validation and ( 'trglang' not in local_var_params or # noqa: E501 local_var_params['trglang'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `trglang` when calling `register_segment`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'source' in local_var_params and local_var_params[ 'source'] is not None: # noqa: E501 query_params.append( ('source', local_var_params['source'])) # noqa: E501 if 'srclang' in local_var_params and local_var_params[ 'srclang'] is not None: # noqa: E501 query_params.append( ('srclang', local_var_params['srclang'])) # noqa: E501 if 'trglang' in local_var_params and local_var_params[ 'trglang'] is not None: # noqa: E501 query_params.append( ('trglang', local_var_params['trglang'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/translate/register', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='TranslateRegisterResponse', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def translate_segment_with_http_info(self, memory_id, **kwargs): # noqa: E501 """Translate a segment # noqa: E501 Translate a source string. Setting the `rich` parameter to `true` will change the response format to include additional information about each translation including a model score, word alignments, and formatting information. The rich format can be seen in the example response on this page. By default, this endpoint also returns translation memory (TM) fuzzy matches, along with associated scores. Fuzzy matches always appear ahead of machine translation output in the response. The maximum source length is 5,000 characters. Usage charges apply to this endpoint for production REST API keys. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.translate_segment_with_http_info(memory_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int memory_id: A unique Memory identifier. (required) :param str source: The source text to be translated. :param int source_hash: A source hash code. :param str prefix: A target prefix. :param int n: Return top n translations. :param bool rich: Returns rich translation information (e.g., with word alignments). :param bool tm_matches: Include translation memory fuzzy matches. :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(TranslationList, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'memory_id', 'source', 'source_hash', 'prefix', 'n', 'rich', 'tm_matches' ] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method translate_segment" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'memory_id' is set if self.api_client.client_side_validation and ( 'memory_id' not in local_var_params or # noqa: E501 local_var_params['memory_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `memory_id` when calling `translate_segment`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'memory_id' in local_var_params and local_var_params[ 'memory_id'] is not None: # noqa: E501 query_params.append( ('memory_id', local_var_params['memory_id'])) # noqa: E501 if 'source' in local_var_params and local_var_params[ 'source'] is not None: # noqa: E501 query_params.append( ('source', local_var_params['source'])) # noqa: E501 if 'source_hash' in local_var_params and local_var_params[ 'source_hash'] is not None: # noqa: E501 query_params.append( ('source_hash', local_var_params['source_hash'])) # noqa: E501 if 'prefix' in local_var_params and local_var_params[ 'prefix'] is not None: # noqa: E501 query_params.append( ('prefix', local_var_params['prefix'])) # noqa: E501 if 'n' in local_var_params and local_var_params[ 'n'] is not None: # noqa: E501 query_params.append(('n', local_var_params['n'])) # noqa: E501 if 'rich' in local_var_params and local_var_params[ 'rich'] is not None: # noqa: E501 query_params.append( ('rich', local_var_params['rich'])) # noqa: E501 if 'tm_matches' in local_var_params and local_var_params[ 'tm_matches'] is not None: # noqa: E501 query_params.append( ('tm_matches', local_var_params['tm_matches'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/translate', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='TranslationList', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): """Perform requests. :param method: http request method :param url: http request url :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. """ method = method.upper() assert method in [ 'GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS' ] if post_params and body: raise ApiValueError( "body parameter cannot be used with post_params parameter.") post_params = post_params or {} headers = headers or {} timeout = None if _request_timeout: if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) elif (isinstance(_request_timeout, tuple) and len(_request_timeout) == 2): timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: url += '?' + urlencode(query_params) if re.search('json', headers['Content-Type'], re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) elif headers[ 'Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, headers=headers) elif headers['Content-Type'] == 'multipart/form-data': # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. del headers['Content-Type'] r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, headers=headers) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided arguments. Please check that your arguments match declared content type.""" raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: r = self.pool_manager.request(method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) if _preload_content: r = RESTResponse(r) # In the python 3, the response.data is bytes. # we need to decode it to string. if six.PY3: r.data = r.data.decode('utf8') # log response body logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: raise ApiException(http_resp=r) return r
def upload_file_with_http_info(self, name, body, **kwargs): # noqa: E501 """Upload a File # noqa: E501 Upload a File in any of the formats [documented in our knowledge base](https://support.lilt.com/hc/en-us/articles/360020816253-File-Formats). Request parameters should be passed in as query string parameters. When uploading a file, any parameters needed to issue a request to the specified export_uri can be encoded in the export_uri itself as query parameters. Typical examples of parameters that may be required are an access token to authorize requests to a third-party HTTP API and the unique identifier of a resource available via the third-party HTTP API that corresponds to the file. An example export_uri that encodes a target resource identifier (i.e., source_id) of an associated resource behind a third party HTTP API is given in the cURL command below. Example cURL command: ``` curl -X POST https://lilt.com/2/files?key=API_KEY&name=en_US.json&export_uri=https://example.com/export?source_id=12345 \\ --header \"Content-Type: application/octet-stream\" \\ --data-binary @en_US.json ``` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.upload_file_with_http_info(name, body, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str name: A file name. (required) :param str body: The file contents to be uploaded. The entire POST body will be treated as the file. (required) :param str export_uri: A webhook endpoint that will export the translated document back to the source repository. :param str file_hash: A hash value to associate with the file. The MD5 hash of the body contents will be used by default if a value isn't provided. :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(File, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['name', 'body', 'export_uri', 'file_hash'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method upload_file" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'name' is set if self.api_client.client_side_validation and ( 'name' not in local_var_params or # noqa: E501 local_var_params['name'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `name` when calling `upload_file`" ) # noqa: E501 # verify the required parameter 'body' is set if self.api_client.client_side_validation and ( 'body' not in local_var_params or # noqa: E501 local_var_params['body'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `body` when calling `upload_file`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'name' in local_var_params and local_var_params[ 'name'] is not None: # noqa: E501 query_params.append( ('name', local_var_params['name'])) # noqa: E501 if 'export_uri' in local_var_params and local_var_params[ 'export_uri'] is not None: # noqa: E501 query_params.append( ('export_uri', local_var_params['export_uri'])) # noqa: E501 if 'file_hash' in local_var_params and local_var_params[ 'file_hash'] is not None: # noqa: E501 query_params.append( ('file_hash', local_var_params['file_hash'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/octet-stream']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/files', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='File', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def query_lexicon_with_http_info(self, memory_id, srclang, trglang, query, **kwargs): # noqa: E501 """Query a Lexicon # noqa: E501 Query the Lexicon. The Lexicon is an editable termbase / concordance that is integrated with the Memory. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.query_lexicon_with_http_info(memory_id, srclang, trglang, query, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int memory_id: A unique Memory identifier. (required) :param str srclang: An ISO 639-1 language code. (required) :param str trglang: An ISO 639-1 language code. (required) :param str query: The query term. (required) :param int n: The maximum number of results to return. :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(list[LexiconEntry], status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['memory_id', 'srclang', 'trglang', 'query', 'n'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method query_lexicon" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'memory_id' is set if self.api_client.client_side_validation and ('memory_id' not in local_var_params or # noqa: E501 local_var_params['memory_id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `memory_id` when calling `query_lexicon`") # noqa: E501 # verify the required parameter 'srclang' is set if self.api_client.client_side_validation and ('srclang' not in local_var_params or # noqa: E501 local_var_params['srclang'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `srclang` when calling `query_lexicon`") # noqa: E501 # verify the required parameter 'trglang' is set if self.api_client.client_side_validation and ('trglang' not in local_var_params or # noqa: E501 local_var_params['trglang'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `trglang` when calling `query_lexicon`") # noqa: E501 # verify the required parameter 'query' is set if self.api_client.client_side_validation and ('query' not in local_var_params or # noqa: E501 local_var_params['query'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `query` when calling `query_lexicon`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'memory_id' in local_var_params and local_var_params['memory_id'] is not None: # noqa: E501 query_params.append(('memory_id', local_var_params['memory_id'])) # noqa: E501 if 'srclang' in local_var_params and local_var_params['srclang'] is not None: # noqa: E501 query_params.append(('srclang', local_var_params['srclang'])) # noqa: E501 if 'trglang' in local_var_params and local_var_params['trglang'] is not None: # noqa: E501 query_params.append(('trglang', local_var_params['trglang'])) # noqa: E501 if 'query' in local_var_params and local_var_params['query'] is not None: # noqa: E501 query_params.append(('query', local_var_params['query'])) # noqa: E501 if 'n' in local_var_params and local_var_params['n'] is not None: # noqa: E501 query_params.append(('n', local_var_params['n'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/lexicon', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='list[LexiconEntry]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def qa_check_with_http_info(self, target, trglang, **kwargs): # noqa: E501 """Perform QA check # noqa: E501 Perform QA checks on a target string. Optionally, you can specify a source string for additional bilingual checks, e.g. number consistency. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.qa_check_with_http_info(target, trglang, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str target: A target string to be checked. (required) :param str trglang: An ISO 639-1 language code. (required) :param str source: An optional source string. :param str srclang: An ISO 639-1 language code. :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(QARuleMatches, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['target', 'trglang', 'source', 'srclang'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method qa_check" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'target' is set if self.api_client.client_side_validation and ('target' not in local_var_params or # noqa: E501 local_var_params['target'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `target` when calling `qa_check`") # noqa: E501 # verify the required parameter 'trglang' is set if self.api_client.client_side_validation and ('trglang' not in local_var_params or # noqa: E501 local_var_params['trglang'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `trglang` when calling `qa_check`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'target' in local_var_params and local_var_params['target'] is not None: # noqa: E501 query_params.append(('target', local_var_params['target'])) # noqa: E501 if 'trglang' in local_var_params and local_var_params['trglang'] is not None: # noqa: E501 query_params.append(('trglang', local_var_params['trglang'])) # noqa: E501 if 'source' in local_var_params and local_var_params['source'] is not None: # noqa: E501 query_params.append(('source', local_var_params['source'])) # noqa: E501 if 'srclang' in local_var_params and local_var_params['srclang'] is not None: # noqa: E501 query_params.append(('srclang', local_var_params['srclang'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/qa', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='QARuleMatches', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def tag_segment_with_http_info(self, source_tagged, target, memory_id, **kwargs): # noqa: E501 """Tag a Segment # noqa: E501 Project tags for a segment. The `source_tagged` string contains one or more SGML tags. The `target` string is untagged. This endpoint will automatically place the source tags in the target. Usage charges apply to this endpoint for production REST API keys. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.tag_segment_with_http_info(source_tagged, target, memory_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str source_tagged: The tagged source string. (required) :param str target: The target string. (required) :param int memory_id: A unique Memory identifier. (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(TaggedSegment, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['source_tagged', 'target', 'memory_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method tag_segment" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'source_tagged' is set if self.api_client.client_side_validation and ( 'source_tagged' not in local_var_params or # noqa: E501 local_var_params['source_tagged'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `source_tagged` when calling `tag_segment`" ) # noqa: E501 # verify the required parameter 'target' is set if self.api_client.client_side_validation and ( 'target' not in local_var_params or # noqa: E501 local_var_params['target'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `target` when calling `tag_segment`" ) # noqa: E501 # verify the required parameter 'memory_id' is set if self.api_client.client_side_validation and ( 'memory_id' not in local_var_params or # noqa: E501 local_var_params['memory_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `memory_id` when calling `tag_segment`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'source_tagged' in local_var_params and local_var_params[ 'source_tagged'] is not None: # noqa: E501 query_params.append( ('source_tagged', local_var_params['source_tagged'])) # noqa: E501 if 'target' in local_var_params and local_var_params[ 'target'] is not None: # noqa: E501 query_params.append( ('target', local_var_params['target'])) # noqa: E501 if 'memory_id' in local_var_params and local_var_params[ 'memory_id'] is not None: # noqa: E501 query_params.append( ('memory_id', local_var_params['memory_id'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['ApiKeyAuth', 'BasicAuth'] # noqa: E501 return self.api_client.call_api( '/segments/tag', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='TaggedSegment', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)