|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Phrase Strings API Reference |
| 5 | +
|
| 6 | + The version of the OpenAPI document: 2.0.0 |
| 7 | + Contact: support@phrase.com |
| 8 | + Generated by: https://openapi-generator.tech |
| 9 | +""" |
| 10 | + |
| 11 | + |
| 12 | +from __future__ import absolute_import |
| 13 | + |
| 14 | +import re # noqa: F401 |
| 15 | + |
| 16 | +# python 2 and python 3 compatibility library |
| 17 | +import six |
| 18 | + |
| 19 | +from phrase_api.api_client import ApiClient |
| 20 | +from phrase_api.exceptions import ( # noqa: F401 |
| 21 | + ApiTypeError, |
| 22 | + ApiValueError |
| 23 | +) |
| 24 | + |
| 25 | + |
| 26 | +class UploadBatchesApi(object): |
| 27 | + """NOTE: This class is auto generated by OpenAPI Generator |
| 28 | + Ref: https://openapi-generator.tech |
| 29 | +
|
| 30 | + Do not edit the class manually. |
| 31 | + """ |
| 32 | + |
| 33 | + def __init__(self, api_client=None): |
| 34 | + if api_client is None: |
| 35 | + api_client = ApiClient() |
| 36 | + self.api_client = api_client |
| 37 | + |
| 38 | + def upload_batches_create(self, project_id, upload_batches_create_parameters, **kwargs): # noqa: E501 |
| 39 | + """Create upload batch # noqa: E501 |
| 40 | +
|
| 41 | + Groups multiple file uploads into a single batch. Optionally, launches the deletion of unmentioned translation keys after all uploads in the batch are completed. # noqa: E501 |
| 42 | + This method makes a synchronous HTTP request by default. To make an |
| 43 | + asynchronous HTTP request, please pass async_req=True |
| 44 | + >>> thread = api.upload_batches_create(project_id, upload_batches_create_parameters, async_req=True) |
| 45 | + >>> result = thread.get() |
| 46 | +
|
| 47 | + :param async_req bool: execute request asynchronously |
| 48 | + :param str project_id: Project ID (required) |
| 49 | + :param UploadBatchesCreateParameters upload_batches_create_parameters: (required) |
| 50 | + :param str x_phrase_app_otp: Two-Factor-Authentication token (optional) |
| 51 | + :param _preload_content: if False, the urllib3.HTTPResponse object will |
| 52 | + be returned without reading/decoding response |
| 53 | + data. Default is True. |
| 54 | + :param _request_timeout: timeout setting for this request. If one |
| 55 | + number provided, it will be total request |
| 56 | + timeout. It can also be a pair (tuple) of |
| 57 | + (connection, read) timeouts. |
| 58 | + :return: UploadBatch |
| 59 | + If the method is called asynchronously, |
| 60 | + returns the request thread. |
| 61 | + """ |
| 62 | + kwargs['_return_http_data_only'] = True |
| 63 | + return self.upload_batches_create_with_http_info(project_id, upload_batches_create_parameters, **kwargs) # noqa: E501 |
| 64 | + |
| 65 | + def upload_batches_create_with_http_info(self, project_id, upload_batches_create_parameters, **kwargs): # noqa: E501 |
| 66 | + """Create upload batch # noqa: E501 |
| 67 | +
|
| 68 | + Groups multiple file uploads into a single batch. Optionally, launches the deletion of unmentioned translation keys after all uploads in the batch are completed. # noqa: E501 |
| 69 | + This method makes a synchronous HTTP request by default. To make an |
| 70 | + asynchronous HTTP request, please pass async_req=True |
| 71 | + >>> thread = api.upload_batches_create_with_http_info(project_id, upload_batches_create_parameters, async_req=True) |
| 72 | + >>> result = thread.get() |
| 73 | +
|
| 74 | + :param async_req bool: execute request asynchronously |
| 75 | + :param str project_id: Project ID (required) |
| 76 | + :param UploadBatchesCreateParameters upload_batches_create_parameters: (required) |
| 77 | + :param str x_phrase_app_otp: Two-Factor-Authentication token (optional) |
| 78 | + :param _return_http_data_only: response data without head status code |
| 79 | + and headers |
| 80 | + :param _preload_content: if False, the urllib3.HTTPResponse object will |
| 81 | + be returned without reading/decoding response |
| 82 | + data. Default is True. |
| 83 | + :param _request_timeout: timeout setting for this request. If one |
| 84 | + number provided, it will be total request |
| 85 | + timeout. It can also be a pair (tuple) of |
| 86 | + (connection, read) timeouts. |
| 87 | + :return: tuple(UploadBatch, status_code(int), headers(HTTPHeaderDict)) |
| 88 | + If the method is called asynchronously, |
| 89 | + returns the request thread. |
| 90 | + """ |
| 91 | + |
| 92 | + local_var_params = locals() |
| 93 | + |
| 94 | + all_params = [ |
| 95 | + 'project_id', |
| 96 | + 'upload_batches_create_parameters', |
| 97 | + 'x_phrase_app_otp' |
| 98 | + ] |
| 99 | + all_params.extend( |
| 100 | + [ |
| 101 | + 'async_req', |
| 102 | + '_return_http_data_only', |
| 103 | + '_preload_content', |
| 104 | + '_request_timeout' |
| 105 | + ] |
| 106 | + ) |
| 107 | + |
| 108 | + for key, val in six.iteritems(local_var_params['kwargs']): |
| 109 | + if key not in all_params: |
| 110 | + raise ApiTypeError( |
| 111 | + "Got an unexpected keyword argument '%s'" |
| 112 | + " to method upload_batches_create" % key |
| 113 | + ) |
| 114 | + local_var_params[key] = val |
| 115 | + del local_var_params['kwargs'] |
| 116 | + # verify the required parameter 'project_id' is set |
| 117 | + if self.api_client.client_side_validation and ('project_id' not in local_var_params or # noqa: E501 |
| 118 | + local_var_params['project_id'] is None): # noqa: E501 |
| 119 | + raise ApiValueError("Missing the required parameter `project_id` when calling `upload_batches_create`") # noqa: E501 |
| 120 | + # verify the required parameter 'upload_batches_create_parameters' is set |
| 121 | + if self.api_client.client_side_validation and ('upload_batches_create_parameters' not in local_var_params or # noqa: E501 |
| 122 | + local_var_params['upload_batches_create_parameters'] is None): # noqa: E501 |
| 123 | + raise ApiValueError("Missing the required parameter `upload_batches_create_parameters` when calling `upload_batches_create`") # noqa: E501 |
| 124 | + |
| 125 | + collection_formats = {} |
| 126 | + |
| 127 | + path_params = {} |
| 128 | + if 'project_id' in local_var_params: |
| 129 | + path_params['project_id'] = local_var_params['project_id'] # noqa: E501 |
| 130 | + |
| 131 | + query_params = [] |
| 132 | + |
| 133 | + header_params = {} |
| 134 | + if 'x_phrase_app_otp' in local_var_params: |
| 135 | + header_params['X-PhraseApp-OTP'] = local_var_params['x_phrase_app_otp'] # noqa: E501 |
| 136 | + |
| 137 | + form_params = [] |
| 138 | + local_var_files = {} |
| 139 | + |
| 140 | + body_params = None |
| 141 | + if 'upload_batches_create_parameters' in local_var_params: |
| 142 | + body_params = local_var_params['upload_batches_create_parameters'] |
| 143 | + # HTTP header `Accept` |
| 144 | + header_params['Accept'] = self.api_client.select_header_accept( |
| 145 | + ['application/json']) # noqa: E501 |
| 146 | + |
| 147 | + # HTTP header `Content-Type` |
| 148 | + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 |
| 149 | + ['application/json']) # noqa: E501 |
| 150 | + |
| 151 | + # Authentication setting |
| 152 | + auth_settings = ['Basic', 'Token'] # noqa: E501 |
| 153 | + |
| 154 | + return self.api_client.call_api( |
| 155 | + '/projects/{project_id}/upload_batches', 'POST', |
| 156 | + path_params, |
| 157 | + query_params, |
| 158 | + header_params, |
| 159 | + body=body_params, |
| 160 | + post_params=form_params, |
| 161 | + files=local_var_files, |
| 162 | + response_type='UploadBatch', # noqa: E501 |
| 163 | + auth_settings=auth_settings, |
| 164 | + async_req=local_var_params.get('async_req'), |
| 165 | + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 |
| 166 | + _preload_content=local_var_params.get('_preload_content', True), |
| 167 | + _request_timeout=local_var_params.get('_request_timeout'), |
| 168 | + collection_formats=collection_formats) |
0 commit comments