コード例 #1
0
    def cancel_purchase_new_with_http_info(self, aid, pid, **kwargs):  # noqa: E501
        """Cancel Recurring Subscription  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.cancel_purchase_new_with_http_info(aid, pid, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str aid: (required)
        :param str pid: (required)
        :param bool cancel_immediately:
        :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: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['aid', 'pid', 'cancel_immediately']  # 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 cancel_purchase_new" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'aid' is set
        if ('aid' not in local_var_params or
                local_var_params['aid'] is None):
            raise ApiValueError("Missing the required parameter `aid` when calling `cancel_purchase_new`")  # noqa: E501
        # verify the required parameter 'pid' is set
        if ('pid' not in local_var_params or
                local_var_params['pid'] is None):
            raise ApiValueError("Missing the required parameter `pid` when calling `cancel_purchase_new`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'aid' in local_var_params:
            path_params['aid'] = local_var_params['aid']  # noqa: E501
        if 'pid' in local_var_params:
            path_params['pid'] = local_var_params['pid']  # noqa: E501

        query_params = []
        if 'cancel_immediately' in local_var_params:
            query_params.append(('cancelImmediately', local_var_params['cancel_immediately']))  # 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/vnd.onshape.v1+json;charset=UTF-8;qs=0.1', 'application/json;charset=UTF-8; qs=0.09'])  # noqa: E501

        # Authentication setting
        auth_settings = ['OAuth2']  # noqa: E501

        return self.api_client.call_api(
            '/api/accounts/{aid}/purchases/{pid}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)
コード例 #2
0
    def call_with_http_info(self, **kwargs):

        try:
            _host = self.settings['servers'][kwargs['_host_index']]
        except IndexError:
            if self.settings['servers']:
                raise ApiValueError(
                    "Invalid host index. Must be 0 <= index < %s" %
                    len(self.settings['servers']))
            _host = None

        for key, value in six.iteritems(kwargs):
            if key not in self.params_map['all']:
                raise ApiTypeError("Got an unexpected parameter '%s'"
                                   " to method `%s`" %
                                   (key, self.settings['operation_id']))
            # only throw this nullable ApiValueError if _check_input_type
            # is False, if _check_input_type==True we catch this case
            # in self.__validate_inputs
            if (key not in self.params_map['nullable'] and value is None
                    and kwargs['_check_input_type'] is False):
                raise ApiValueError(
                    "Value may not be None for non-nullable parameter `%s`"
                    " when calling `%s`" %
                    (key, self.settings['operation_id']))

        for key in self.params_map['required']:
            if key not in kwargs.keys():
                raise ApiValueError(
                    "Missing the required parameter `%s` when calling "
                    "`%s`" % (key, self.settings['operation_id']))

        self.__validate_inputs(kwargs)

        params = self.__gather_params(kwargs)

        accept_headers_list = self.headers_map['accept']
        if accept_headers_list:
            params['header']['Accept'] = self.api_client.select_header_accept(
                accept_headers_list)

        content_type_headers_list = self.headers_map['content_type']
        if content_type_headers_list:
            header_list = self.api_client.select_header_content_type(
                content_type_headers_list)
            params['header']['Content-Type'] = header_list

        return self.api_client.call_api(
            self.settings['endpoint_path'],
            self.settings['http_method'],
            params['path'],
            params['query'],
            params['header'],
            body=params['body'],
            post_params=params['form'],
            files=params['file'],
            response_type=self.settings['response_type'],
            auth_settings=self.settings['auth'],
            async_req=kwargs['async_req'],
            _check_type=kwargs['_check_return_type'],
            _return_http_data_only=kwargs['_return_http_data_only'],
            _preload_content=kwargs['_preload_content'],
            _request_timeout=kwargs['_request_timeout'],
            _host=_host,
            collection_formats=params['collection_format'])
コード例 #3
0
    def call_with_http_info(self, **kwargs):

        try:
            _host = self.settings["servers"][kwargs["_host_index"]]
        except IndexError:
            if self.settings["servers"]:
                raise ApiValueError(
                    "Invalid host index. Must be 0 <= index < %s" %
                    len(self.settings["servers"]))
            _host = None

        for key, value in six.iteritems(kwargs):
            if key not in self.params_map["all"]:
                raise ApiTypeError("Got an unexpected parameter '%s'"
                                   " to method `%s`" %
                                   (key, self.settings["operation_id"]))
            # only throw this nullable ApiValueError if _check_input_type
            # is False, if _check_input_type==True we catch this case
            # in self.__validate_inputs
            if (key not in self.params_map["nullable"] and value is None
                    and kwargs["_check_input_type"] is False):
                raise ApiValueError(
                    "Value may not be None for non-nullable parameter `%s`"
                    " when calling `%s`" %
                    (key, self.settings["operation_id"]))

        for key in self.params_map["required"]:
            if key not in kwargs.keys():
                raise ApiValueError(
                    "Missing the required parameter `%s` when calling "
                    "`%s`" % (key, self.settings["operation_id"]))

        self.__validate_inputs(kwargs)

        params = self.__gather_params(kwargs)

        accept_headers_list = self.headers_map["accept"]
        if accept_headers_list:
            params["header"]["Accept"] = self.api_client.select_header_accept(
                accept_headers_list)

        content_type_headers_list = self.headers_map["content_type"]
        if content_type_headers_list:
            header_list = self.api_client.select_header_content_type(
                content_type_headers_list)
            params["header"]["Content-Type"] = header_list

        return self.api_client.call_api(
            self.settings["endpoint_path"],
            self.settings["http_method"],
            params["path"],
            params["query"],
            params["header"],
            body=params["body"],
            post_params=params["form"],
            files=params["file"],
            response_type=self.settings["response_type"],
            auth_settings=self.settings["auth"],
            async_req=kwargs["async_req"],
            _check_type=kwargs["_check_return_type"],
            _return_http_data_only=kwargs["_return_http_data_only"],
            _preload_content=kwargs["_preload_content"],
            _request_timeout=kwargs["_request_timeout"],
            _host=_host,
            collection_formats=params["collection_format"],
        )
コード例 #4
0
    def get_plan_purchases_with_http_info(self, plan_id, **kwargs):  # noqa: E501
        """Get Plan Purchases  # 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_plan_purchases_with_http_info(plan_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str plan_id: (required)
        :param int offset:
        :param int limit:
        :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(BTListResponseBTPurchaseInfo, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['plan_id', 'offset', 'limit']  # 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_plan_purchases" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'plan_id' is set
        if ('plan_id' not in local_var_params or
                local_var_params['plan_id'] is None):
            raise ApiValueError("Missing the required parameter `plan_id` when calling `get_plan_purchases`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'plan_id' in local_var_params:
            path_params['planId'] = local_var_params['plan_id']  # noqa: E501

        query_params = []
        if 'offset' in local_var_params:
            query_params.append(('offset', local_var_params['offset']))  # noqa: E501
        if 'limit' in local_var_params:
            query_params.append(('limit', local_var_params['limit']))  # 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/vnd.onshape.v1+json;charset=UTF-8;qs=0.1', 'application/json;charset=UTF-8; qs=0.09'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/api/accounts/plans/{planId}/purchases', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='BTListResponseBTPurchaseInfo',  # 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)
コード例 #5
0
    def create_feature_studio_with_http_info(self, did, wid,
                                             bt_model_element_params,
                                             **kwargs):  # noqa: E501
        """create_feature_studio  # 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_feature_studio_with_http_info(did, wid, bt_model_element_params, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str did: (required)
        :param str wid: (required)
        :param BTModelElementParams bt_model_element_params: (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: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['did', 'wid', 'bt_model_element_params']  # 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_feature_studio" % key)
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'did' is set
        if ('did' not in local_var_params or local_var_params['did'] is None):
            raise ApiValueError(
                "Missing the required parameter `did` when calling `create_feature_studio`"
            )  # noqa: E501
        # verify the required parameter 'wid' is set
        if ('wid' not in local_var_params or local_var_params['wid'] is None):
            raise ApiValueError(
                "Missing the required parameter `wid` when calling `create_feature_studio`"
            )  # noqa: E501
        # verify the required parameter 'bt_model_element_params' is set
        if ('bt_model_element_params' not in local_var_params
                or local_var_params['bt_model_element_params'] is None):
            raise ApiValueError(
                "Missing the required parameter `bt_model_element_params` when calling `create_feature_studio`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'did' in local_var_params:
            path_params['did'] = local_var_params['did']  # noqa: E501
        if 'wid' in local_var_params:
            path_params['wid'] = local_var_params['wid']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'bt_model_element_params' in local_var_params:
            body_params = local_var_params['bt_model_element_params']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept([
            'application/vnd.onshape.v1+json;charset=UTF-8;qs=0.1',
            'application/json;charset=UTF-8; qs=0.09'
        ])  # noqa: E501

        # HTTP header `Content-Type`
        header_params[
            'Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
                ['application/json;charset=UTF-8; qs=0.09'])  # noqa: E501

        # Authentication setting
        auth_settings = ['OAuth2']  # noqa: E501

        return self.api_client.call_api(
            '/api/featurestudios/d/{did}/w/{wid}',
            'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)
コード例 #6
0
    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"

        # Ethan added:
        headers, multipart_boundary = add_onshape_specific_headers(
            method,
            url,
            self.configuration,
            query_params=query_params,
            headers=headers)

        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 "multipart/form-data" in headers["Content-Type"]:
                    # must del headers['Content-Type'], or the correct
                    # Content-Type which is 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,
                        multipart_boundary=multipart_boundary,
                    )
                # 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,
                    redirect=False,
                )
        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)

        # TODO: Handle redirections
        # Ethan added the below clause to handle redirects correctly:
        if 300 <= r.status <= 399:
            # parse location
            location_string = r.getheaders()["Location"]
            location = urlparse(location_string)
            new_url = location.scheme + "://" + location.netloc + location.path
            logger.debug("request redirected to: " + location_string)
            parsed_qs = parse_qs(location.query)
            for q in parsed_qs:
                parsed_qs[q] = parsed_qs[q][0]
            return self.request(
                method,
                new_url,
                headers=headers,
                query_params=parsed_qs,
                body=body,
                post_params=post_params,
                _preload_content=_preload_content,
                _request_timeout=_request_timeout,
            )

        if r.status == 403 or r.status == 401:
            from onshape_client.client import Client

            client = Client.get_client()
            if client.get_authentication_method() == "oauth":
                client.do_oauth_flow()
                headers["Authorization"] = "Bearer {}".format(
                    client.configuration.access_token)
                return self.request(
                    method,
                    url,
                    query_params=query_params,
                    headers=headers,
                    body=body,
                    post_params=post_params,
                    _preload_content=_preload_content,
                    _request_timeout=_request_timeout,
                )

        if not 200 <= r.status <= 299:
            raise ApiException(http_resp=r)

        return r
コード例 #7
0
 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,
                                         post_params=post_params,
                                         _preload_content=_preload_content,
                                         _request_timeout=_request_timeout,
                                         body=body)
     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`.")
コード例 #8
0
    def download_file_workspace_with_http_info(self, did, wid, eid,
                                               **kwargs):  # noqa: E501
        """download_file_workspace  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.download_file_workspace_with_http_info(did, wid, eid, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str did: (required)
        :param str wid: (required)
        :param str eid: (required)
        :param str content_disposition:
        :param str if_none_match:
        :param str link_document_id:
        :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: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'did', 'wid', 'eid', 'content_disposition', 'if_none_match',
            'link_document_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 download_file_workspace" % key)
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'did' is set
        if ('did' not in local_var_params or local_var_params['did'] is None):
            raise ApiValueError(
                "Missing the required parameter `did` when calling `download_file_workspace`"
            )  # noqa: E501
        # verify the required parameter 'wid' is set
        if ('wid' not in local_var_params or local_var_params['wid'] is None):
            raise ApiValueError(
                "Missing the required parameter `wid` when calling `download_file_workspace`"
            )  # noqa: E501
        # verify the required parameter 'eid' is set
        if ('eid' not in local_var_params or local_var_params['eid'] is None):
            raise ApiValueError(
                "Missing the required parameter `eid` when calling `download_file_workspace`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'did' in local_var_params:
            path_params['did'] = local_var_params['did']  # noqa: E501
        if 'wid' in local_var_params:
            path_params['wid'] = local_var_params['wid']  # noqa: E501
        if 'eid' in local_var_params:
            path_params['eid'] = local_var_params['eid']  # noqa: E501

        query_params = []
        if 'content_disposition' in local_var_params:
            query_params.append(
                ('contentDisposition',
                 local_var_params['content_disposition']))  # noqa: E501
        if 'link_document_id' in local_var_params:
            query_params.append(
                ('linkDocumentId',
                 local_var_params['link_document_id']))  # noqa: E501

        header_params = {}
        if 'if_none_match' in local_var_params:
            header_params['If-None-Match'] = local_var_params[
                'if_none_match']  # noqa: E501

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept([
            'application/vnd.onshape.v1+octet-stream;charset=UTF-8;qs=0.1',
            'application/json;charset=UTF-8; qs=0.09',
            'application/octet-stream'
        ])  # noqa: E501

        # Authentication setting
        auth_settings = ['OAuth2']  # noqa: E501

        return self.api_client.call_api(
            '/api/blobelements/d/{did}/w/{wid}/e/{eid}',
            'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)
コード例 #9
0
    def upload_file_create_element_with_http_info(self, did, wid,
                                                  **kwargs):  # noqa: E501
        """upload_file_create_element  # 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_create_element_with_http_info(did, wid, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str did: (required)
        :param str wid: (required)
        :param ContentDisposition content_disposition:
        :param object entity:
        :param BodyPartMediaType media_type:
        :param object message_body_workers:
        :param MultiPart parent:
        :param object providers:
        :param list[BodyPart] body_parts:
        :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: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'did', 'wid', 'content_disposition', 'entity', 'media_type',
            'message_body_workers', 'parent', 'providers', 'body_parts'
        ]  # 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_create_element" %
                                   key)
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'did' is set
        if ('did' not in local_var_params or local_var_params['did'] is None):
            raise ApiValueError(
                "Missing the required parameter `did` when calling `upload_file_create_element`"
            )  # noqa: E501
        # verify the required parameter 'wid' is set
        if ('wid' not in local_var_params or local_var_params['wid'] is None):
            raise ApiValueError(
                "Missing the required parameter `wid` when calling `upload_file_create_element`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'did' in local_var_params:
            path_params['did'] = local_var_params['did']  # noqa: E501
        if 'wid' in local_var_params:
            path_params['wid'] = local_var_params['wid']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'content_disposition' in local_var_params:
            form_params.append(
                ('contentDisposition',
                 local_var_params['content_disposition']))  # noqa: E501
        if 'entity' in local_var_params:
            form_params.append(
                ('entity', local_var_params['entity']))  # noqa: E501
        if 'media_type' in local_var_params:
            form_params.append(
                ('mediaType', local_var_params['media_type']))  # noqa: E501
        if 'message_body_workers' in local_var_params:
            form_params.append(
                ('messageBodyWorkers',
                 local_var_params['message_body_workers']))  # noqa: E501
        if 'parent' in local_var_params:
            form_params.append(
                ('parent', local_var_params['parent']))  # noqa: E501
        if 'providers' in local_var_params:
            form_params.append(
                ('providers', local_var_params['providers']))  # noqa: E501
        if 'body_parts' in local_var_params:
            form_params.append(
                ('bodyParts', local_var_params['body_parts']))  # noqa: E501
            collection_formats['bodyParts'] = 'csv'  # noqa: E501

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept([
            'application/vnd.onshape.v1+json;charset=UTF-8;qs=0.1',
            'application/json;charset=UTF-8; qs=0.09'
        ])  # noqa: E501

        # HTTP header `Content-Type`
        header_params[
            'Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
                ['multipart/form-data'])  # noqa: E501

        # Authentication setting
        auth_settings = ['OAuth2']  # noqa: E501

        return self.api_client.call_api(
            '/api/blobelements/d/{did}/w/{wid}',
            'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)