Example #1
0
    def update_params_for_auth(self, headers, querys, auth_settings,
                               resource_path, method, body):
        """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.
        :param resource_path: A string representation of the HTTP request resource path.
        :param method: A string representation of the HTTP request method.
        :param body: A object representing the body of the HTTP request.
            The object type is the return value of _encoder.default().
        """
        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':
                    if auth_setting['type'] != 'http-signature':
                        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`')
Example #2
0
 def sanitize_for_serialization(cls, obj):
     """Builds a JSON POST object.
     If obj is None, return None.
     If obj is str, int, long, float, bool, return directly.
     If obj is datetime.datetime, datetime.date
         convert to string in iso8601 format.
     If obj is list, sanitize each element in the list.
     If obj is dict, return the dict.
     If obj is OpenAPI model, return the properties dict.
     :param obj: The data to serialize.
     :return: The serialized form of data.
     """
     if isinstance(obj, (ModelNormal, ModelComposed)):
         return {
             key: cls.sanitize_for_serialization(val)
             for key, val in model_to_dict(obj, serialize=True).items()
         }
     elif isinstance(obj, (str, int, float, none_type, bool)):
         return obj
     elif isinstance(obj, (datetime, date)):
         return obj.isoformat()
     elif isinstance(obj, ModelSimple):
         return cls.sanitize_for_serialization(obj.value)
     elif isinstance(obj, (list, tuple)):
         return [cls.sanitize_for_serialization(item) for item in obj]
     if isinstance(obj, dict):
         return {
             key: cls.sanitize_for_serialization(val)
             for key, val in obj.items()
         }
     raise ApiValueError(
         'Unable to prepare type {} for serialization'.format(
             obj.__class__.__name__))
Example #3
0
    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`')
Example #4
0
    def files_parameters(
        self,
        files: typing.Optional[typing.Dict[str,
                                           typing.List[io.IOBase]]] = None):
        """Builds form parameters.

        :param files: None or a dict with key=param_name and
            value is a list of open file objects
        :return: List of tuples of form parameters with file data
        """
        if files is None:
            return []

        params = []
        for param_name, file_instances in files.items():
            if file_instances is None:
                # if the file field is nullable, skip None values
                continue
            for file_instance in file_instances:
                if file_instance is None:
                    # if the file field is nullable, skip None values
                    continue
                if file_instance.closed is True:
                    raise ApiValueError(
                        "Cannot read a closed file. The passed in file_type "
                        "for %s must be open." % param_name)
                filename = os.path.basename(file_instance.name)
                filedata = file_instance.read()
                mimetype = (mimetypes.guess_type(filename)[0]
                            or 'application/octet-stream')
                params.append(
                    tuple([param_name,
                           tuple([filename, filedata, mimetype])]))
                file_instance.close()

        return params
Example #5
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'

        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)

            # log response body
            logger.debug("response body: %s", r.data)

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

        return r
Example #6
0
    def post_cq_actions_with_http_info(self, authorizable_id, changelog, **kwargs):  # noqa: E501
        """post_cq_actions  # noqa: E501

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

        :param async_req bool: execute request asynchronously
        :param str authorizable_id: (required)
        :param str changelog: (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 = [
            'authorizable_id',
            'changelog'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 post_cq_actions" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'authorizable_id' is set
        if self.api_client.client_side_validation and ('authorizable_id' not in local_var_params or  # noqa: E501
                                                        local_var_params['authorizable_id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `authorizable_id` when calling `post_cq_actions`")  # noqa: E501
        # verify the required parameter 'changelog' is set
        if self.api_client.client_side_validation and ('changelog' not in local_var_params or  # noqa: E501
                                                        local_var_params['changelog'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `changelog` when calling `post_cq_actions`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'authorizable_id' in local_var_params and local_var_params['authorizable_id'] is not None:  # noqa: E501
            query_params.append(('authorizableId', local_var_params['authorizable_id']))  # noqa: E501
        if 'changelog' in local_var_params and local_var_params['changelog'] is not None:  # noqa: E501
            query_params.append(('changelog', local_var_params['changelog']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # Authentication setting
        auth_settings = ['aemAuth']  # noqa: E501

        return self.api_client.call_api(
            '/.cqactions.html', '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)
Example #7
0
    def ssl_setup_with_http_info(self, keystore_password, keystore_password_confirm, truststore_password, truststore_password_confirm, https_hostname, https_port, **kwargs):  # noqa: E501
        """ssl_setup  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.ssl_setup_with_http_info(keystore_password, keystore_password_confirm, truststore_password, truststore_password_confirm, https_hostname, https_port, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str keystore_password: (required)
        :param str keystore_password_confirm: (required)
        :param str truststore_password: (required)
        :param str truststore_password_confirm: (required)
        :param str https_hostname: (required)
        :param str https_port: (required)
        :param file privatekey_file:
        :param file certificate_file:
        :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(str, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'keystore_password',
            'keystore_password_confirm',
            'truststore_password',
            'truststore_password_confirm',
            'https_hostname',
            'https_port',
            'privatekey_file',
            'certificate_file'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 ssl_setup" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'keystore_password' is set
        if self.api_client.client_side_validation and ('keystore_password' not in local_var_params or  # noqa: E501
                                                        local_var_params['keystore_password'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `keystore_password` when calling `ssl_setup`")  # noqa: E501
        # verify the required parameter 'keystore_password_confirm' is set
        if self.api_client.client_side_validation and ('keystore_password_confirm' not in local_var_params or  # noqa: E501
                                                        local_var_params['keystore_password_confirm'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `keystore_password_confirm` when calling `ssl_setup`")  # noqa: E501
        # verify the required parameter 'truststore_password' is set
        if self.api_client.client_side_validation and ('truststore_password' not in local_var_params or  # noqa: E501
                                                        local_var_params['truststore_password'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `truststore_password` when calling `ssl_setup`")  # noqa: E501
        # verify the required parameter 'truststore_password_confirm' is set
        if self.api_client.client_side_validation and ('truststore_password_confirm' not in local_var_params or  # noqa: E501
                                                        local_var_params['truststore_password_confirm'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `truststore_password_confirm` when calling `ssl_setup`")  # noqa: E501
        # verify the required parameter 'https_hostname' is set
        if self.api_client.client_side_validation and ('https_hostname' not in local_var_params or  # noqa: E501
                                                        local_var_params['https_hostname'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `https_hostname` when calling `ssl_setup`")  # noqa: E501
        # verify the required parameter 'https_port' is set
        if self.api_client.client_side_validation and ('https_port' not in local_var_params or  # noqa: E501
                                                        local_var_params['https_port'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `https_port` when calling `ssl_setup`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'keystore_password' in local_var_params and local_var_params['keystore_password'] is not None:  # noqa: E501
            query_params.append(('keystorePassword', local_var_params['keystore_password']))  # noqa: E501
        if 'keystore_password_confirm' in local_var_params and local_var_params['keystore_password_confirm'] is not None:  # noqa: E501
            query_params.append(('keystorePasswordConfirm', local_var_params['keystore_password_confirm']))  # noqa: E501
        if 'truststore_password' in local_var_params and local_var_params['truststore_password'] is not None:  # noqa: E501
            query_params.append(('truststorePassword', local_var_params['truststore_password']))  # noqa: E501
        if 'truststore_password_confirm' in local_var_params and local_var_params['truststore_password_confirm'] is not None:  # noqa: E501
            query_params.append(('truststorePasswordConfirm', local_var_params['truststore_password_confirm']))  # noqa: E501
        if 'https_hostname' in local_var_params and local_var_params['https_hostname'] is not None:  # noqa: E501
            query_params.append(('httpsHostname', local_var_params['https_hostname']))  # noqa: E501
        if 'https_port' in local_var_params and local_var_params['https_port'] is not None:  # noqa: E501
            query_params.append(('httpsPort', local_var_params['https_port']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'privatekey_file' in local_var_params:
            local_var_files['privatekeyFile'] = local_var_params['privatekey_file']  # noqa: E501
        if 'certificate_file' in local_var_params:
            local_var_files['certificateFile'] = local_var_params['certificate_file']  # noqa: E501

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # 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 = ['aemAuth']  # noqa: E501

        return self.api_client.call_api(
            '/libs/granite/security/post/sslSetup.html', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # 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)
Example #8
0
    def post_set_password_with_http_info(self, old, plain, verify,
                                         **kwargs):  # noqa: E501
        """post_set_password  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.post_set_password_with_http_info(old, plain, verify, async_req=True)
        >>> result = thread.get()

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

        local_var_params = locals()

        all_params = ['old', 'plain', 'verify']
        all_params.extend([
            'async_req', '_return_http_data_only', '_preload_content',
            '_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 post_set_password" % key)
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'old' is set
        if self.api_client.client_side_validation and (
                'old' not in local_var_params or  # noqa: E501
                local_var_params['old'] is None):  # noqa: E501
            raise ApiValueError(
                "Missing the required parameter `old` when calling `post_set_password`"
            )  # noqa: E501
        # verify the required parameter 'plain' is set
        if self.api_client.client_side_validation and (
                'plain' not in local_var_params or  # noqa: E501
                local_var_params['plain'] is None):  # noqa: E501
            raise ApiValueError(
                "Missing the required parameter `plain` when calling `post_set_password`"
            )  # noqa: E501
        # verify the required parameter 'verify' is set
        if self.api_client.client_side_validation and (
                'verify' not in local_var_params or  # noqa: E501
                local_var_params['verify'] is None):  # noqa: E501
            raise ApiValueError(
                "Missing the required parameter `verify` when calling `post_set_password`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'old' in local_var_params and local_var_params[
                'old'] is not None:  # noqa: E501
            query_params.append(('old', local_var_params['old']))  # noqa: E501
        if 'plain' in local_var_params and local_var_params[
                'plain'] is not None:  # noqa: E501
            query_params.append(
                ('plain', local_var_params['plain']))  # noqa: E501
        if 'verify' in local_var_params and local_var_params[
                'verify'] is not None:  # noqa: E501
            query_params.append(
                ('verify', local_var_params['verify']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

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

        return self.api_client.call_api(
            '/crx/explorer/ui/setpassword.jsp',
            'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # 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)
Example #9
0
    def post_package_service_json_with_http_info(self, path, cmd,
                                                 **kwargs):  # noqa: E501
        """post_package_service_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.post_package_service_json_with_http_info(path, cmd, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str path: (required)
        :param str cmd: (required)
        :param str group_name:
        :param str package_name:
        :param str package_version:
        :param str charset_:
        :param bool force:
        :param bool recursive:
        :param file package:
        :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(str, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'path', 'cmd', 'group_name', 'package_name', 'package_version',
            'charset_', 'force', 'recursive', 'package'
        ]
        all_params.extend([
            'async_req', '_return_http_data_only', '_preload_content',
            '_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 post_package_service_json" %
                                   key)
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'path' is set
        if self.api_client.client_side_validation and (
                'path' not in local_var_params or  # noqa: E501
                local_var_params['path'] is None):  # noqa: E501
            raise ApiValueError(
                "Missing the required parameter `path` when calling `post_package_service_json`"
            )  # noqa: E501
        # verify the required parameter 'cmd' is set
        if self.api_client.client_side_validation and (
                'cmd' not in local_var_params or  # noqa: E501
                local_var_params['cmd'] is None):  # noqa: E501
            raise ApiValueError(
                "Missing the required parameter `cmd` when calling `post_package_service_json`"
            )  # noqa: E501

        collection_formats = {}

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

        query_params = []
        if 'cmd' in local_var_params and local_var_params[
                'cmd'] is not None:  # noqa: E501
            query_params.append(('cmd', local_var_params['cmd']))  # noqa: E501
        if 'group_name' in local_var_params and local_var_params[
                'group_name'] is not None:  # noqa: E501
            query_params.append(
                ('groupName', local_var_params['group_name']))  # noqa: E501
        if 'package_name' in local_var_params and local_var_params[
                'package_name'] is not None:  # noqa: E501
            query_params.append(
                ('packageName',
                 local_var_params['package_name']))  # noqa: E501
        if 'package_version' in local_var_params and local_var_params[
                'package_version'] is not None:  # noqa: E501
            query_params.append(
                ('packageVersion',
                 local_var_params['package_version']))  # noqa: E501
        if 'charset_' in local_var_params and local_var_params[
                'charset_'] is not None:  # noqa: E501
            query_params.append(
                ('_charset_', local_var_params['charset_']))  # noqa: E501
        if 'force' in local_var_params and local_var_params[
                'force'] is not None:  # noqa: E501
            query_params.append(
                ('force', local_var_params['force']))  # noqa: E501
        if 'recursive' in local_var_params and local_var_params[
                'recursive'] is not None:  # noqa: E501
            query_params.append(
                ('recursive', local_var_params['recursive']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'package' in local_var_params:
            local_var_files['package'] = local_var_params[
                'package']  # noqa: E501

        body_params = None
        # 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
                ['multipart/form-data'])  # noqa: E501

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

        return self.api_client.call_api(
            '/crx/packmgr/service/.json/{path}',
            'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # 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)
Example #10
0
    def call_with_http_info(self, **kwargs):

        try:
            index = self.api_client.configuration.server_operation_index.get(
                self.settings['operation_id'],
                self.api_client.configuration.server_index
            ) if kwargs['_host_index'] is None else kwargs['_host_index']
            server_variables = self.api_client.configuration.server_operation_variables.get(
                self.settings['operation_id'],
                self.api_client.configuration.server_variables)
            _host = self.api_client.configuration.get_host_from_settings(
                index,
                variables=server_variables,
                servers=self.settings['servers'])
        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 kwargs.items():
            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'])
Example #11
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`.")