jnpr/space/resource.py
def post(self, accept=None, content_type=None, request_body=None,
             task_monitor=None, schedule=None, *args, **kwargs):
        """
        Some resources support the POST method. For example, the configuration
        of a device supports the POST method which can be used to fetch
        selected portions of the configuration based on xpath expressions.
        On such resources, this method can be used to send the POST request.

        :param str accept: This can be used to supply a media-type that must
            be used as the Accept header in the request. This defaults to
            ``None`` and in this case SpaceEZ will use the media-type modeled
            in the description file.

        :param str content_type: This can be used to supply a media-type that must
            be used as the Content-Type header in the request. This defaults to
            ``None`` and in this case SpaceEZ will use the media-type modeled
            in the description file.

        :param str request_body: This can be used to supply a string that must
            be used as the request body in the request. This defaults to
            ``None`` and in this case SpaceEZ will create the request body
            using the modeled template, replacing variables with kwargs.

        :param task_monitor: A TaskMonitor object that can be used to monitor
            the progress of the POST request, in case of asynchronous
            invocations. You need to check Junos Space API documentation to
            see if the POST invocation on this resource has asynchronous
            semantics and supply the task_monitor parameter only if it is
            asynchronous. Otherwise, this will default to ``None`` and the
            method will behave with synchronous semantics.
        :type task_monitor: jnpr.space.async.TaskMonitor

        :param str schedule: A string specifying a cron expression for
            scheduling the execution of the request on the Space server side.
            This is applicable only if the POST invocation on this resource
            has asynchronous semantics and you want to schedule the execution.
            Otherwise, this will default to ``None``.

        :param kwargs: Keyword args of the form name=value which will be used
            to substitute variables in a pre-defined template (if applicable)
            to form the request body.
        :type kwargs: A variable list of name=value arguments.

        :returns: A Python object constructed from the response body that Space
            returned for the POST method invocation. In the case of asynchronous
            invocation, this will represent a Task object and will contain the
            unique id of the Task executing the POST request in Space.

        :raises: ``jnpr.space.rest.RestException`` if the POST method results in
            an error response. The exception's ``response`` attribute will have
            the full response from Space.

        """
        url = self.get_href()
        if task_monitor is not None:
            url = '?queue='.join([url, task_monitor.get_queue_url()])
            if schedule is not None:
                url = '&schedule='.join([url, schedule])

        headers = {}
        if accept is not None:
            headers['accept'] = accept
        elif self._meta_object.response_type is not None:
            headers['accept'] = self._meta_object.response_type

        if content_type is not None:
            headers['content-type'] = content_type
        elif self._meta_object.request_type is not None:
            headers['content-type'] = self._meta_object.request_type

        if request_body is not None:
            body = request_body
        elif self._meta_object.request_template is not None:
            body = self._meta_object.request_template.render(**kwargs)
        else:
            body = None

        response = self._rest_end_point.post(url, headers, body)
        if (response.status_code != 202) and (response.status_code != 200):
            raise rest.RestException("POST failed on %s" % url, response)

        resp_text = xmlutil.get_text_from_response(response)
        resp_text = xmlutil.cleanup(resp_text)
        if self._meta_object.remove_junos_group:
            resp_text = xmlutil.remove_junos_group(resp_text)
        return xmlutil.xml2obj(resp_text)

        Some resources support the POST method. For example, the configuration
        of a device supports the POST method which can be used to fetch
        selected portions of the configuration based on xpath expressions.
        On such resources, this method can be used to send the POST request.

        :param str accept: This can be used to supply a media-type that must
            be used as the Accept header in the request. This defaults to
            ``None`` and in this case SpaceEZ will use the media-type modeled
            in the description file.

        :param str content_type: This can be used to supply a media-type that must
            be used as the Content-Type header in the request. This defaults to
            ``None`` and in this case SpaceEZ will use the media-type modeled
            in the description file.

        :param str request_body: This can be used to supply a string that must
            be used as the request body in the request. This defaults to
            ``None`` and in this case SpaceEZ will create the request body
            using the modeled template, replacing variables with kwargs.

        :param task_monitor: A TaskMonitor object that can be used to monitor
            the progress of the POST request, in case of asynchronous
            invocations. You need to check Junos Space API documentation to
            see if the POST invocation on this resource has asynchronous
            semantics and supply the task_monitor parameter only if it is
            asynchronous. Otherwise, this will default to ``None`` and the
            method will behave with synchronous semantics.
        :type task_monitor: jnpr.space.async.TaskMonitor

        :param str schedule: A string specifying a cron expression for
            scheduling the execution of the request on the Space server side.
            This is applicable only if the POST invocation on this resource
            has asynchronous semantics and you want to schedule the execution.
            Otherwise, this will default to ``None``.

        :param kwargs: Keyword args of the form name=value which will be used
            to substitute variables in a pre-defined template (if applicable)
            to form the request body.
        :type kwargs: A variable list of name=value arguments.

        :returns: A Python object constructed from the response body that Space
            returned for the POST method invocation. In the case of asynchronous
            invocation, this will represent a Task object and will contain the
            unique id of the Task executing the POST request in Space.

        :raises: ``jnpr.space.rest.RestException`` if the POST method results in
            an error response. The exception's ``response`` attribute will have
            the full response from Space.

        
Some resources support the POST method. For example, the configuration
of a device supports the POST method which can be used to fetch
selected portions of the configuration based on xpath expressions.
On such resources, this method can be used to send the POST request.
Some resources support the POST method . For example the configuration of a device supports the POST method which can be used to fetch selected portions of the configuration based on xpath expressions . On such resources this method can be used to send the POST request .
def post(self, accept=None, content_type=None, request_body=None,
             task_monitor=None, schedule=None, *args, **kwargs):
        url = self.get_href()
        if task_monitor is not None:
            url = '?queue='.join([url, task_monitor.get_queue_url()])
            if schedule is not None:
                url = '&schedule='.join([url, schedule])
        headers = {}
        if accept is not None:
            headers['accept'] = accept
        elif self._meta_object.response_type is not None:
            headers['accept'] = self._meta_object.response_type
        if content_type is not None:
            headers['content-type'] = content_type
        elif self._meta_object.request_type is not None:
            headers['content-type'] = self._meta_object.request_type
        if request_body is not None:
            body = request_body
        elif self._meta_object.request_template is not None:
            body = self._meta_object.request_template.render(**kwargs)
        else:
            body = None
        response = self._rest_end_point.post(url, headers, body)
        if (response.status_code != 202) and (response.status_code != 200):
            raise rest.RestException("POST failed on %s" % url, response)
        resp_text = xmlutil.get_text_from_response(response)
        resp_text = xmlutil.cleanup(resp_text)
        if self._meta_object.remove_junos_group:
            resp_text = xmlutil.remove_junos_group(resp_text)
        return xmlutil.xml2obj(resp_text)
def post ( self , accept = None , content_type = None , request_body = None , task_monitor = None , schedule = None , * args , ** kwargs ) : url = self . get_href ( ) if task_monitor is not None : url = '?queue=' . join ( [ url , task_monitor . get_queue_url ( ) ] ) if schedule is not None : url = '&schedule=' . join ( [ url , schedule ] ) headers = { } if accept is not None : headers [ 'accept' ] = accept elif self . _meta_object . response_type is not None : headers [ 'accept' ] = self . _meta_object . response_type if content_type is not None : headers [ 'content-type' ] = content_type elif self . _meta_object . request_type is not None : headers [ 'content-type' ] = self . _meta_object . request_type if request_body is not None : body = request_body elif self . _meta_object . request_template is not None : body = self . _meta_object . request_template . render ( ** kwargs ) else : body = None response = self . _rest_end_point . post ( url , headers , body ) if ( response . status_code != 202 ) and ( response . status_code != 200 ) : raise rest . RestException ( "POST failed on %s" % url , response ) resp_text = xmlutil . get_text_from_response ( response ) resp_text = xmlutil . cleanup ( resp_text ) if self . _meta_object . remove_junos_group : resp_text = xmlutil . remove_junos_group ( resp_text ) return xmlutil . xml2obj ( resp_text )
Some resources support the POST method.
Some resources support the POST method .
"""
        Some resources support the POST method. For example, the configuration
        of a device supports the POST method which can be used to fetch
        selected portions of the configuration based on xpath expressions.
        On such resources, this method can be used to send the POST request.

        :param str accept: This can be used to supply a media-type that must
            be used as the Accept header in the request. This defaults to
            ``None`` and in this case SpaceEZ will use the media-type modeled
            in the description file.

        :param str content_type: This can be used to supply a media-type that must
            be used as the Content-Type header in the request. This defaults to
            ``None`` and in this case SpaceEZ will use the media-type modeled
            in the description file.

        :param str request_body: This can be used to supply a string that must
            be used as the request body in the request. This defaults to
            ``None`` and in this case SpaceEZ will create the request body
            using the modeled template, replacing variables with kwargs.

        :param task_monitor: A TaskMonitor object that can be used to monitor
            the progress of the POST request, in case of asynchronous
            invocations. You need to check Junos Space API documentation to
            see if the POST invocation on this resource has asynchronous
            semantics and supply the task_monitor parameter only if it is
            asynchronous. Otherwise, this will default to ``None`` and the
            method will behave with synchronous semantics.
        :type task_monitor: jnpr.space.async.TaskMonitor

        :param str schedule: A string specifying a cron expression for
            scheduling the execution of the request on the Space server side.
            This is applicable only if the POST invocation on this resource
            has asynchronous semantics and you want to schedule the execution.
            Otherwise, this will default to ``None``.

        :param kwargs: Keyword args of the form name=value which will be used
            to substitute variables in a pre-defined template (if applicable)
            to form the request body.
        :type kwargs: A variable list of name=value arguments.

        :returns: A Python object constructed from the response body that Space
            returned for the POST method invocation. In the case of asynchronous
            invocation, this will represent a Task object and will contain the
            unique id of the Task executing the POST request in Space.

        :raises: ``jnpr.space.rest.RestException`` if the POST method results in
            an error response. The exception's ``response`` attribute will have
            the full response from Space.

        """
A Python object constructed from the response body that Space
returned for the POST method invocation. In the case of asynchronous
invocation, this will represent a Task object and will contain the
unique id of the Task executing the POST request in Space.
A Python object constructed from the response body that Space returned for the POST method invocation . In the case of asynchronous invocation this will represent a Task object and will contain the unique id of the Task executing the POST request in Space .
``jnpr.space.rest.RestException`` if the POST method results in
an error response. The exception's ``response`` attribute will have
the full response from Space.
` ` jnpr . space . rest . RestException ` ` if the POST method results in an error response . The exception ' s ` ` response ` ` attribute will have the full response from Space .
self
accept
This can be used to supply a media-type that must
be used as the Accept header in the request. This defaults to
``None`` and in this case SpaceEZ will use the media-type modeled
in the description file.
This can be used to supply a media - type that must be used as the Accept header in the request . This defaults to ` ` None ` ` and in this case SpaceEZ will use the media - type modeled in the description file .
content_type
This can be used to supply a media-type that must
be used as the Content-Type header in the request. This defaults to
``None`` and in this case SpaceEZ will use the media-type modeled
in the description file.
This can be used to supply a media - type that must be used as the Content - Type header in the request . This defaults to ` ` None ` ` and in this case SpaceEZ will use the media - type modeled in the description file .
request_body
This can be used to supply a string that must
be used as the request body in the request. This defaults to
``None`` and in this case SpaceEZ will create the request body
using the modeled template, replacing variables with kwargs.
This can be used to supply a string that must be used as the request body in the request . This defaults to ` ` None ` ` and in this case SpaceEZ will create the request body using the modeled template replacing variables with kwargs .
task_monitor
A TaskMonitor object that can be used to monitor
the progress of the POST request, in case of asynchronous
invocations. You need to check Junos Space API documentation to
see if the POST invocation on this resource has asynchronous
semantics and supply the task_monitor parameter only if it is
asynchronous. Otherwise, this will default to ``None`` and the
method will behave with synchronous semantics.
A TaskMonitor object that can be used to monitor the progress of the POST request in case of asynchronous invocations . You need to check Junos Space API documentation to see if the POST invocation on this resource has asynchronous semantics and supply the task_monitor parameter only if it is asynchronous . Otherwise this will default to ` ` None ` ` and the method will behave with synchronous semantics .
schedule
A string specifying a cron expression for
scheduling the execution of the request on the Space server side.
This is applicable only if the POST invocation on this resource
has asynchronous semantics and you want to schedule the execution.
Otherwise, this will default to ``None``.
A string specifying a cron expression for scheduling the execution of the request on the Space server side . This is applicable only if the POST invocation on this resource has asynchronous semantics and you want to schedule the execution . Otherwise this will default to ` ` None ` ` .
kwargs
Keyword args of the form name=value which will be used
to substitute variables in a pre-defined template (if applicable)
to form the request body.
Keyword args of the form name = value which will be used to substitute variables in a pre - defined template ( if applicable ) to form the request body .